我的htaccess重写规则适用于本地主机/ mysite的,但不是在mysite.com上的1和1共享主机 [英] My htaccess RewriteRule works on localhost/mysite but not at mysite.com on a 1&1 shared host

查看:237
本文介绍了我的htaccess重写规则适用于本地主机/ mysite的,但不是在mysite.com上的1和1共享主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决:

遗憾的是,该解决方案是不是一个令人满意的。今天上午,试图@ WIGE的建议的时候,我才发现,我的惊喜,该预期值INFACT发送到网页作为 GET 查询。显然,1和1(谁知道一直在改变他们的环境中,这最后的几个星期),没有落后pviously unworking code的神奇固定我的问题的场面,现在我所有的$ P $的东西的的工作作为最初的预期。


新资讯:在的Apache 的版本,生产服务器是 1.3.34 VS 2.2.21 我的本地主机的。

我无法弄清楚,为什么我重写规则是不正常的生产。

  

重写规则^页/ pretty的-URL /(.*)$ page.php?查询= $ 1 [L]

在我的本地测试环境(本地主机/ mysite的/网页/ pretty的-URL /{...})它工作正常,但 mysite.com/page/$p$ptty-url /{...}它不能正常工作。它加载 page.php 如预期,但显然?查询= $ 1 片被忽略( $ _ GET 是空的)

我想,这个问题以某种方式与服务器配置。我在一1和1共享的主机没有httpd.conf文件访问帐户。


什么是重写规则做(或的做):

我要像

网址
  

* example.com/page/$p$ptty-url / {{info_for_dynamic_content}}

要被改写为

  

* /page.php?query = {{info_for_dynamic_content}}

所以,我可以访问的 info_for_dynamic_content

PHP $ _ GET ['查询']


供参考的完整.htaccess文件:

 的AddHandler的X MAPP-PHP6的.php

的DirectoryIndex index.php文件
的ErrorDocument 404的index.php

选项​​+的FollowSymLinks

#每@Jacques切斯特的建议
选项​​-MultiViews

RewriteEngine叙述上
的RewriteBase /

#有关规则
重写规则^页/ pretty的-URL /(.*)$ page.php?查询= $ 1 [L]

的RewriteCond%{REQUEST_FILENAME} \ PHP -f
重写规则^(。*)$ $ 1.PHP

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{REQUEST_FILENAME} \ php的!-f
重写规则(。*)的index.php [L]
 

解决方案

最有可能的,你的主机存储变量别处。我想补充一个调用phpinfo();到脚本,并通过环境变量那里看看,如果你能找到,应该已经在获取值。

Solved:

unfortunately, the solution is not a satisfying one. This morning, when trying @Wige's Suggestion, I found, to my suprise, that the Expected values WERE infact sent to the page as a GET query. Apparently, 1&1 (who I know have been making changes to their environment this last couple weeks), did something behind the scenes which magically fixed my problem, and now all of my previously unworking code is working as originally expected.


New info: The Apache version of the production server is 1.3.34 vs 2.2.21 on my localhost.

I'm having trouble figuring out why my RewriteRule is not working properly in production.

RewriteRule ^page/pretty-url/(.*)$ page.php?query=$1 [L]

In my local testing environment (localhost/mysite/page/pretty-url/{...}) it works fine, but on mysite.com/page/pretty-url/{...} it doesn't work properly. It loads page.php as expected but apparently the ?query=$1 piece is ignored ($_GET is empty)

I imagine that the problem is somehow related to the server configuration. I'm on a 1&1 shared hosting account with no httpd.conf access.


What that RewriteRule does (or should do):

I want urls like

*example.com/page/pretty-url/{{info_for_dynamic_content}}

to be rewritten to

*/page.php?query={{info_for_dynamic_content}}

So I can access info_for_dynamic_content

within php as $_GET['query']


The full .htaccess file for reference:

AddHandler x-mapp-php6 .php

DirectoryIndex index.php
ErrorDocument 404 /index.php 

Options +FollowSymLinks

# per @Jacques Chester's suggestion
Options -MultiViews

RewriteEngine on
RewriteBase /

# the rule in question
RewriteRule ^page/pretty-url/(.*)$ page.php?query=$1 [L]

RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php !-f 
RewriteRule (.*) /index.php [L]

解决方案

Most likely, your host is storing the variables somewhere else. I would add a call to phpinfo(); into your script and go through the environment variables there to see if you can find the values that should have been in get.

这篇关于我的htaccess重写规则适用于本地主机/ mysite的,但不是在mysite.com上的1和1共享主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆