.htaccess rewrite changes error url -
i have made redirecting stuff in .htaccess , works quiet well.
rewriteengine on # add together www. if missing rewritecond %{http_host} !^www\.example\.com$ [nc] rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] # redirect index.html , index.php simple homepage rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\|/index\.html\ http/ rewriterule ^index\.php$|^index\.html$ http://www.example.com/ [r=301,l] # add together trailing slash if missing rewritecond %{request_filename} !-f rewriterule ^.*[^/]$ /$0/ [l,r=301] # redirect simulated directories php files of same name in /content/ rewritecond %{request_uri} !^(\/css|\/images) [nc] rewriterule ^([^/]+)/$ content/$1\.php?rw=1 [qsa,l] rewritecond %{query_string} !^rw=1 rewriterule ^content/([^/]+).php$ /$1/ [r=301,l]
but while part adds trailing slashes enabled there unusual issue urls don't exist , directed 404 error page: example, if come in www.example.com/notexisting/ url transformed www.example.com/content/notexisting.php/?rw=1 not happen when disable part trailing slashes or 1 simulated directories in htaccess. want maintain both. there possibility?
it looks can quite prepare problem adding status 'slash' redirect. don't seem have url's end on .php, can check if url ends that. if not case, can add together slash.
rewriteengine on # add together www. if missing rewritecond %{http_host} !^www\.example\.com$ [nc] rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] # redirect index.html , index.php simple homepage rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\|/index\.html\ http/ rewriterule ^index\.php$|^index\.html$ http://www.example.com/ [r=301,l] # add together trailing slash if missing rewritecond %{request_filename} !-f rewritecond %{request_uri} !\.php$ rewriterule ^.*[^/]$ /$0/ [l,r=301] # redirect simulated directories php files of same name in /content/ rewritecond %{request_uri} !^(\/css|\/images) [nc] rewriterule ^([^/]+)/$ content/$1\.php?rw=1 [qsa,l] rewritecond %{query_string} !^rw=1 rewriterule ^content/([^/]+).php$ /$1/ [r=301,l]
.htaccess mod-rewrite
No comments:
Post a Comment