actually am trying to make seo friendly url's with.htaccess but my.htaccess file is not working in cpanel. this code is working fine in localhost that's my code for.htaccess file
#Remove .php extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteEngine On
RewriteRule ^projects/([^/\.]+)/?$ project-detail?p=$1
RewriteRule ^category/([0-9a-zA-z]+)/?$ category-detail?c=$1
RewriteRule ^post/([^/\.]+)/?$ post-detail?p=$1
how can i fix this?
Try it like this instead:
Options -MultiViews
RewriteEngine on
RewriteRule ^projects/([^/.]+)/?$ project-detail.php?p=$1 [L]
RewriteRule ^category/([0-9a-zA-z]+)/?$ category-detail.php?c=$1 [L]
RewriteRule ^post/([^/.]+)/?$ post-detail.php?p=$1 [L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)$ $1.php [L]
(Although post-detail.php
does not seem to exist on your site.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.