簡體   English   中英

刪除.PHP並通過htaccess重定向

[英]Remove .PHP and redirect through htaccess

是否可以隱藏.PHP擴展名並同時重定向URL。

示例: http//example.com/test需要重定向到http://someothersite.com

 Options +FollowSymlinks
 RewriteEngine on
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.php -f
 RewriteRule ^(.*)$ $1.php
 RewriteRule ^(.*)/test http://someothersite.com

但它不起作用。

任何想法 ?

謝謝

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteRule ^test http://someothersite.com [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

上面的代碼沒有經過測試,但它應該讓你對它有所了解。 在每組規則之后使用L標志 ,因為它停止處理其余規則。

你需要這個:

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)$ $1.php [R=301,L]

對於跨域重寫:

RewriteRule ^test http://someothersite.com [R=301,L]

總是使用L = 301進行永久重定向。

暫無
暫無

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

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