i have this url
http://myurl.com/shiftturn/index.php?m=value
and i want:
http://myurl.com/shiftturn/value
this is my .htaccess
RewriteEngine On
RewriteRule /shiftturn/([^/]*)$ /index.php?m=$1 [L]
but doesn't work.
how can I do to get the kind of url I need, with a correct htaccess expression?
Place this rule in /shiftturn/.htaccess:
RewriteEngine On
RewriteBase /shiftturn/
RewriteCond %{THE_REQUEST} /index\.php\?m=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?m=$1 [L,QSA]
Related
Modify code to accept parameters via URl. Rules to redirect URLs to www.site.com/acessorios.php tried are as follows, where .htaccess rules file is present along side with app folder.
RewriteEngine ON
RewriteBase /app/views/
##External redirect rules from here.
RewriteCond %{THE_REQUEST} \s/app/views/([^.]*\.php)\s [NC]
RewriteRule ^ /%1? [R=301,L]
##Internal rewrite rules from here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]*\.php)/?$ /app/views/$1 [QSA,L]
Samples:
www.site.com/accessories.php?id=1
www.site.com/accessories.php?id=1&name=Tiago
www.site.com/accessories.php?id=1&name=Tiago&image=foto.png
Samples:
www.site.com/accessories/1
www.site.com/accessories/1/Tiago
www.site.com/accessories/1/Tiago/foto.png
This order may be different
With your shown samples and attempts please try following .htaccess rules file. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /app/views/
##External redirect rules from here....
RewriteCond %{THE_REQUEST} \s/([^.]*)\.php\?id=(\d+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
RewriteCond %{THE_REQUEST} \s/([^.]*)\.php\?id=(\d+)&name=(\S+)\s [NC]
RewriteRUle ^ /%1/%2/%3? [R=301,L]
RewriteCond %{THE_REQUEST} \s/([^.]*)\.php\?id=(\d+)&name=(\S+)&image=(\S+)\s [NC]
RewriteRule ^ /%1/%2/%3/%4? [R=301,L]
##Internal rules from here onwards....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/?$ /app/views/$1.php?id=$2&name=$3&image=$4 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ /app/views/$1.php?id=$2&name=$3 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ /app/views/$1.php?id=$2 [QSA,L]
I'm trying to redirect all urls that contain a specific string. The urls look like this
http://www.domain/com/modules.php?name=Kalender&op=list&d=8&m=6&y=2034
I have to redirect all urls that contain
name=Kalender&
to
http://www.domain.com/kalender/
I tried several rules in my .htaccess. None of them worked:
RewriteCond %{REQUEST_URI} name=Kalender&
RewriteRule .* kalender
RewriteRule ^(.)name=Kalender&(.)$ http://www.domain.com/kalender/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/name=Kalender&/i$ http://www.domain.com/kalender/ [NE,L]
RewriteCond %{REQUEST_URI} name=Kalender&
RewriteRule ^(.+)$ http://www.domain.com/kalender/ [L,R=301]
RewriteCond %{QUERY_STRING} ^name=Kalender&
RewriteRule ^name=Kalender& http://www.domain.com/kalender/ [R=301,L]
RewriteRule ^(.*)name=Kalender&(.*)$ http://www.domain.com/kalender/ [L,R=301]
RewriteCond %{REQUEST_URI} ^/modules.php?name=Kalender&$
RewriteRule ^(.*) http://www.domain.com/kalender [R=301,L]
This is the WordPress .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any help would be appreciated!
You can use this rule as your first rule:
RewriteCond %{QUERY_STRING} (^|&)name=Kalender(&|$) [NC]
RewriteRule ^ /kalender/? [L,R]
I have this url: http://example.org/product.php?course_id=$x
And I want this url changes to this: http://example.org/Course-Name
this is my code in .htaccess file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ 404page.php
RewriteRule ^/([0-9]+)/([^/]+)/$ /product.php?course_id=$1 [L,R]
Which is not working kindly tell me whats wrong with my code?
You need to remove leading slash from your rule. Try this rule:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+product\.php\?course_id=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /product.php?course_id=$1 [L,QSA]
I've got the following problem:
I need to redirect (301) from /index.php to homepage but there are rewrite rules:
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
And there is a loop of redirects when I add line:
Redirect 301 /index.php http://example.com/
How can I do it without changing the rewrite rules? .htaccess is not clear enough for me
Have your rule like this:
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=301,NC,NE]
RewriteCond %{REQUEST_URI} (\.html?|\.php|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
This code is working fine:
RewriteEngine On
RewriteBase /my/project/dir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /my/project/dir/index.php?uri=$1 [QSA,L]
But now I'd like to force the www. within the URL to avoid duplicate content (SEO). I found this code-snippet, but I'm not able to integrate it into my code:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
I tried a few combinations but I don't want to confuse you. None of them was working.
How would you extend the first (working) code lines to accomplish the goal? Thanks in advance!
Change the order of rules and use %{REQUEST_URI} in 301 rule:
RewriteEngine On
RewriteBase /my/project/dir/
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^ http://www.domain.com%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /my/project/dir/index.php?uri=$1 [QSA,L]