64 位上 xampp windows 10 中的 .htaccess 对搜索引擎友好 URL
Search Engine Friendly URL with .htaccess in xampp windows 10 on 64-bit
我想将 url 更改为对搜索引擎友好。我在 windows 10 上使用 xampp 3.2.1 64 位
我的网址看起来像这样:
http://smc.edu.pk/app/site/?p=12&m=c&u=Swat_Medical_College-_The_Project_of_Swat_Medical_Complex
我想做成这样:
http://smc.edu.pk/app/site/12/c/Swat_Medical_College-_The_Project_of_Swat_Medical_Complex.html
我已经使用 .htaccess
使用以下代码进行了测试
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/app/site/(\d+)/([a-z-]+)/(.+)\.html$ /?p=&m=&u= [NC,L]
但是当我使用上面提到的第二个 url 时 returns 出现以下错误:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
smc.edu.pk
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
我觉得应该是这样的(未测试):
RewriteRule ^/app/site/(\d+)/([a-z-]+)/(.+)\.html$ /app/site/?p=&m=&u= [NC,L]
编辑:应该是这样的(经过测试和工作):
RewriteRule ^app/site/(\d+)/([a-z-]+)/(.+)\.html$ /app/site/?p=&m=&u= [NC,L]
是的,我找到了解决方案:
RewriteEngine On
RewriteBase /app/site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.html$ /app/site/?p=&m=&u= [NC,L]
我已将 RewriteRule 更改为:
RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.html$ /app/site/?p=&m=&u= [NC,L]
并将 RewriteBase /app/site/ 放在第二行。
现在它完美地工作....
我想将 url 更改为对搜索引擎友好。我在 windows 10 上使用 xampp 3.2.1 64 位 我的网址看起来像这样:
http://smc.edu.pk/app/site/?p=12&m=c&u=Swat_Medical_College-_The_Project_of_Swat_Medical_Complex
我想做成这样:
http://smc.edu.pk/app/site/12/c/Swat_Medical_College-_The_Project_of_Swat_Medical_Complex.html
我已经使用 .htaccess
使用以下代码进行了测试RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/app/site/(\d+)/([a-z-]+)/(.+)\.html$ /?p=&m=&u= [NC,L]
但是当我使用上面提到的第二个 url 时 returns 出现以下错误:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
smc.edu.pk
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
我觉得应该是这样的(未测试):
RewriteRule ^/app/site/(\d+)/([a-z-]+)/(.+)\.html$ /app/site/?p=&m=&u= [NC,L]
编辑:应该是这样的(经过测试和工作):
RewriteRule ^app/site/(\d+)/([a-z-]+)/(.+)\.html$ /app/site/?p=&m=&u= [NC,L]
是的,我找到了解决方案:
RewriteEngine On
RewriteBase /app/site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.html$ /app/site/?p=&m=&u= [NC,L]
我已将 RewriteRule 更改为:
RewriteRule ^([^/]+)/([^/]+)/([^/]+)\.html$ /app/site/?p=&m=&u= [NC,L]
并将 RewriteBase /app/site/ 放在第二行。 现在它完美地工作....