簡體   English   中英

Apache Rewrite問題URL帶有多個斜杠

[英]Apache Rewrite issue with url with more than 1 slash

問題基本上是這樣的:

我有一個網址: site.com?go=1&do=2&action3&id=4

如果我使用這樣的重寫方法:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([A-Za-z0-9_-]+)$ /index.php?go=$1
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?go=$1&do=$2
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?go=$1&do=$2&action=$3
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ /index.php?go=$1&do=$2&action=$3&id=$4

它僅適用於第一個斜杠。 例如:

site.com/go >可行,但此site.com/go/do破壞了整個頁面,找不到CSS,img,什么也沒有! 我該如何解決?

謝謝!

您需要在頭上設置<base>標記,並將域名放入href

<head>
<base href="http://www.sample.com/">
</head>

根據您的URL的結構,您可能需要確保您的URL轉義了反向引用。 查看https://httpd.apache.org/docs/trunk/rewrite/flags.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM