当前,我的网站使用以下URL进行工作:
https://www.example.com/post/?some-post-message
我想从URL中删除问号,即。 .htaccess重写,因此当请求以下URL时,将从服务器显示以上页面:
https://www.example.com/post/some-post-message
当地址栏中不存在问号时,我需要浏览器显示带有问号的页面。我还有其他页面使用吗?我想不受影响,即:https://www.example.com/a=122&b=34223555&c=87sd78s7 https://www.example.com/post/send.php?messagesinfo (和其他网址)
这是我当前放在一起的.htaccess文件,该文件不起作用:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
ErrorDocument 404 /404.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ post/(index\.php)?\?([^&\ ]+)
RewriteRule ^ post/%1? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ post/index.php?$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ home/(index\.php)?\?([^&\ ]+)
RewriteRule ^ home/%1? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ home/index.php?$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ build/(index\.php)?\?([^&\ ]+)
RewriteRule ^ build/%1? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ build/index.php?$1 [L]