我想在这里重新写这个网址;
site.com/product.php?s=electricity-at-work-regulations
到
site.com/courses/electricity-at-work-regulations
所以将product.php更改为课程并整理整理网址。
这可能吗?
.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>
答案 0 :(得分:1)
是的,但反过来会更好。 您应该始终在应用程序中调用site.com/courses/electricity-at-work-regulations并将其重新路由到site.com/product.php?s=electricity-at-work-regulations。像
这样的东西RewriteEngine On
RewriteBase /
RewriteRule ^(courses)/([a-zA-Z\-]+)$ product.php?s=$2 [L]