2014-03-26 27 views
1

我嘗試動態URL轉換爲靜態這個目錄監聽器:http://encode-explorer.siineiolekala.net/ 演示:http://encode-explorer.siineiolekala.net/explorer/index.php轉換動態URL靜態的目錄監聽器(「編碼資源管理器」)

動態網址是: http://files.onitex.tmweb.ru/?dir=directory/subdirectory

我想: http://files.onitex.tmweb.ru/directory/subdirectory

我閱讀文檔,寫以下在.htaccess規則:

Options +FollowSymLinks 
RewriteEngine on 
RewriteRule ^([\/\A-Za-z0-9-]+)/?$ /?dir=$1 [L] 

它在此測試儀中工作正常http://htaccess.madewithlove.be/ 但不在目錄監聽器上。 我想我需要顛倒規則。 您能否解釋我,我該如何解決這個問題?

更新:

我目前的.htaccess:

Options +FollowSymLinks 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+?)/?$ /?dir=$1 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.+?)/$ /?dir=$1 [L,QSA] 

回答

1

使用此規則在根.htaccess文件:

Options +FollowSymLinks 
RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+?)/?$ /?dir=$1 [L,QSA] 

RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.+?)/$ /?dir=$1 [L,QSA] 

不要測試它htaccess.madewithlove.be,它不是真的很可靠。在你的本地主機上測試它。

+0

謝謝你的回答!但它不工作:http://files.onitex.tmweb.ru/documentation不起作用,但http://files.onitex.tmweb.ru/?dir=documentation是工作 –

+0

什麼是您的位置.htaccess和你嘗試測試它的URL是什麼? – anubhava

+0

/files/public_html/.htaccess - 是此網站的根目錄(http://files.onitex.tmweb.ru)。 我嘗試使用http://files.onitex.tmweb.ru/documentation對http://files.onitex.tmweb.ru/documentation/subfolder –