dsizd368332 2015-06-25 09:49
浏览 75
已采纳

.htaccess文件无法重命名子文件夹而是找不到页面

I have search alot on google and even on stackoverflow.com too. I have found some good questions and their answer but unfortunately no answer working for me. I have written a cms kind web application in which public access files are on root where control panel files resides on admin folder. Now i want all control panel files should run using http://www.example.com/administrator url, for this i have written this .httacess file.

.htaccess

# BEGIN     
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

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

RewriteRule ^single _single_Page.php [NC,L]
RewriteRule ^single/([A-Za-z0-9-]+)/?$ _single_Page.php?subid=$1 [NC,L]
RewriteRule ^findcontents$ _findContentTitle.php [L,QSA]
#RewriteRule ^findcontents/([A-Za-z0-9-]+)/?$ _findContentTitle.php?data=$1 [L,QSA]
RewriteRule ^search$ _specificPage.php [NC,L] [L,QSA]




# Admin panel redirect settings

RewriteRule ^/administrator(.*)?$ /admin$1 [NC]


RewriteRule ^authenticate _checkaccess.php [NC,L]

</IfModule>

# END 

From root file working fine, but when i tried www.example.com/administrator. I am getting page not found error. Please somebody help me. what i have mistaken in the .htaccess file.

i have been refer for rename folder using rewrite a folder name using .htaccess

I have also tried this code too

RewriteCond %{REQUEST_URI} ^/administrator/(.*)$
RewriteCond %{DOCUMENT_ROOT}/admin/%1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/admin/%1 -d
RewriteRule ^ /admin/%1 [L]

but still i am getting page not found error. just for the knowledge i am using godaddy hosting. above example working fine for localhost. but not working on godaddy hosting.

  • 写回答

1条回答 默认 最新

  • duanji4449 2015-06-25 13:07
    关注

    Try these rules in your root .htaccess:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    
    RewriteRule ^administrator(.*)$ /admin$1 [NC,L]
    RewriteRule ^authenticate _checkaccess.php [NC,L]
    RewriteRule ^single _single_Page.php [NC,L]
    RewriteRule ^single/([A-Za-z0-9-]+)/?$ _single_Page.php?subid=$1 [NC,L]
    RewriteRule ^findcontents$ _findContentTitle.php [L,QSA]
    #RewriteRule ^findcontents/([A-Za-z0-9-]+)/?$ _findContentTitle.php?data=$1 [L,QSA]
    RewriteRule ^search$ _specificPage.php [NC,L] [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^([^.]+)/?$ $1.php [L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题