0
我想在这里重新写这个URL;htaccess mod_rewrite URL问题
site.com/product.php?s=electricity-at-work-regulations
到
site.com/courses/electricity-at-work-regulations
所以更改product.php到课程和一般整齐的URL设置。
这可能吗?
.htacess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^peoplefactor.co.uk$ [NC]
RewriteRule ^(.*)$ http://peoplefactor.co.uk/$1 [L,R=301]
</IfModule>
# Clean URLS
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteRule ^blog/([a-zA-Z0-9-/]+)/preview$ /blog/post.php?s=$1&preview=all [L]
RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
RewriteRule ^course/([a-zA-Z0-9-/]+)$ /course.php?s=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</IfModule>
# Gets rid of www.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
完美,谢谢。 正如您所建议的,我会在应用程序中将其更改为“课程”。你会碰巧知道清理这个网址的最好方法吗? 'site.com/courses.php?S =电力-AT-工作regulations' 阅读 'site.com /场/电-AT-工作regulations'再次 感谢。 – Cameron
从头开始,应该看起来像RewriteRule ^(courses.php \?s \ =)/([a-zA-Z \ - ] +)$ courses/$ 2 [L]无法测试它 – Eric
这似乎适用于我, '重写规则^ course /([a-zA-Z0-9 - /] +)$ /course.php?s=$1 [L]'但现在我的css或js文件都不是加工。这很奇怪,因为当我查看源代码链接时,开发人员工具中没有错误。有任何想法吗? – Cameron