2012-12-27 26 views
1

如何使用的.htaccess重寫URL僅針對特定的網頁?我怎麼可以重寫我的網址只有某些頁面

例如,我想這對網站或在所有頁面,但index.php文件的網頁的index.php但不休息的工作。

我運行中的問題與子域和PHP腳本在那裏,我使用會搞亂的東西URL重定向。下面是我想要使用的那種腳本的一個例子。

Options +FollowSymLinks -MultiViews 

# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

## If the request is for a valid directory 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
## If the request is for a valid file 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
## If the request is for a valid link 
RewriteCond %{REQUEST_FILENAME} -l 
## don't do anything 
RewriteRule^- [L] 

RewriteRule ^([^/]+)/([^/]+)/?$ index.php/?node=$1&id=$2 [L,QSA] 

RewriteRule ^([^/]+)/?$ index.php/?node=$1 [L,QSA] 

任何人都可以點我在正確的方向?

+0

你的問題給出了一些信息,但還遠遠不夠。如果你問,是因爲在問題設置的規則不起作用,所以這是有幫助沒有。發佈一些完整的URL示例,不要期望人們猜測你需要什麼。 –

回答

3

您可以通過URL作爲REQUEST_URI服務器變量:

RewriteCond %{REQUEST_URI} ^(your_url)$ 
RewriteRule %1 do_some_stuff 

舉個例子:

RewriteCond %{REQUEST_URI} ^index.php$ 
RewriteRule %1 - [F] 

或者只是通過它在RewriteRule

RewriteRule ^index.php$ do_some_stuff 
相關問題