![](/img/trans.png)
[英]Where the problem can be in shortening an url in web address with htaccess?
[英]Shortening URL using .htaccess
我的文件夾結構是:
模塊
行政
登錄
文章
我現在的網址是:
本地主機/模塊/管理員/index.php
本地主機/模塊/登錄/登錄.php
本地主機/模塊/文章/articles.php
我想把它改成:
本地主機/索引
本地主機/登錄
本地主機/文章
由於我是使用 .htaccess 文件的初學者,請幫助我如何使用 .htaccess 文件更改 URL
您的文件夾結構很難制定通用規則,但您應該能夠使用這些規則。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(index)/?$ /modules/admin/$1.php [NC,L,QSA]
RewriteRule ^(login|articles)/?$ /modules/$1/$1.php [NC,L,QSA]
嘗試這個
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteRule ^index([^/]*) /admin/index.php [L]
RewriteRule ^login([^/]*) /login/login.php [L]
RewriteRule ^signup([^/]*) /login/signup.php [L]
RewriteRule ^articles([^/]*) /articles/articles.php [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.