简体   繁体   English

如何修复.htaccess 文件在 Cpanel 上不起作用

[英]How to fix htaccess file is not working on Cpanel

actually am trying to make seo friendly url's with.htaccess but my.htaccess file is not working in cpanel.实际上我正在尝试使 seo 友好的 url 与.htaccess 但 my.htaccess 文件在 cpanel 中不起作用。 this code is working fine in localhost that's my code for.htaccess file此代码在 localhost 中运行良好,这是我的 .htaccess 文件代码

#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.) (尽管post-detail.php似乎不存在于您的网站上。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM