Reputation: 3839
My htaccess is as below:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index
RewriteRule ^index\.php$ / [L,R=301]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
# remove .php from URL
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
# restrict .php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^\ ]+\.php($|\ )
RewriteRule \.php$ / [F,L]
# remove .html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)\.html$ /$1 [L,R=301]
ErrorDocument 404 /error-page
ErrorDocument 403 /error-page
RewriteRule ^good-([^-]*)-([^-]*)\.html$ /goodie?
sd=$1&sd=$2 [L]
RewriteRule ^goodies-([^-]*)-([^-]*)$ /goodie_new?
sd=$1&ds=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /goodie_new?
ds=$1&sd=$2&de=$3 [L]
RewriteRule ^blog/([^/.]+)/?$ /blogdetail_fm?prmn=$1 [L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !cityres
RewriteRule ^([^/.]+)/?$ /cityres?cityf=$1 [L]
When i access blog
rewrite URL i.e. http://example.com/blog/title-of-blog
then i am getting 500 Internal Server Error
. I tried adding RewriteCond %{ENV:REDIRECT_STATUS} ^$
but still 500 error is not disappearing.
Please let me know errors and if there is any wrong rules in myhtaccess.
Upvotes: 1
Views: 451
Reputation: 786101
Have it this way:
ErrorDocument 404 /error-page
ErrorDocument 403 /error-page
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{THE_REQUEST} /index\.php
RewriteRule ^index\.php$ / [L,R=301]
# skip files and directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# restrict .php
RewriteCond %{THE_REQUEST} \.php($|\ )
RewriteRule \.php$ / [F,L]
# remove .html
RewriteRule ^([^/.]+)\.html$ /$1 [L,R=301]
RewriteRule ^goodies-([^-]*)-([^-]*)$ goodie_new?sd=$1&ds=$2 [L,QSA]
RewriteRule ^good-([^-]*)-([^-]*)\.html$ goodie?sd=$1&sd=$2 [L,QSA]
RewriteRule ^blog/([^/.]+)/?$ blogdetail_fm?prmn=$1 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ goodie_new?ds=$1&sd=$2&de=$3 [L,QSA]
# remove .php from URL
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond $1 !cityres
RewriteRule ^([^/.]+)/?$ cityres?cityf=$1 [L,QSA]
Upvotes: 1