标签: mod-rewrite

How to create friendly URL

Please follow this URL (sample) http://www.test.com/test/vehicle?chrysler=crysler300 I want to change this URL http://www.test.com/test/vehicle/chrysler/crysler300 like this. I try to do it using .htaccess file, but it not working.

This is the code I used

RewriteRule vehicle/chrysler/(.*) vehicle?chrysler=$1
Run Code Online (Sandbox Code Playgroud)

php url .htaccess mod-rewrite joomla

0
推荐指数
1
解决办法
106
查看次数

从PHP中读取mod_rewrite配置

我有一个PHP软件,用mod_rewrite做漂亮的事情.但是相同的软件应该在没有安装mod_rewrite的服务器上运行.如果安装了mod_rewrite并且是否应用了某个规则,我可以检查我的php代码吗?

例如,像这样:

    if ((mod_rewrite is enabled) and (mod_rewrite_rule is OK)){
        return  createBeautifullLink();
    }else{
        return createUglyLink();
    }
Run Code Online (Sandbox Code Playgroud)

提前致谢

php apache mod-rewrite

0
推荐指数
1
解决办法
953
查看次数

启用mod_rewrite时页面加载多次(并且缺少css)

我已启用mod_rewrite并使用.htaccess文件传递所有请求index.php.

如果我访问URL的

http://localhost/mysite

http://localhost/mysite/abc
Run Code Online (Sandbox Code Playgroud)

页面加载一次.

但是,如果我在路径中添加额外的部分,页面加载三次,我的css文件不包括在内:

http://localhost/mysite/abc/xyz

http://localhost/mysite/abc/xyz/ttt
Run Code Online (Sandbox Code Playgroud)

等等...

全部导致页面加载三次.我可以看到这一点,因为我index.phpEclipse中设置了断点.

这是我的.htaccess档案:

<IfModule mod_rewrite.c>
  RewriteEngine on

  # Block access to "hidden" directories whose names begin with a period. 
  # Files whose names begin with a period are protected by the FilesMatch directive
  # above.
  RewriteRule "(^|/)\." - [F]

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize(). …
Run Code Online (Sandbox Code Playgroud)

php apache .htaccess mod-rewrite url-rewriting

0
推荐指数
1
解决办法
564
查看次数

.htaccess将文件请求重定向到PHP

我需要将*.pe文件的请求重定向到admin.php并将请求的文件作为参数传递.

例如:用户请求"site.com/dir/file.pe",它将被重定向到"admin.php?file = file.pe"

我试过:

<files *.pe> 
ErrorDocument 403 /login/db/admin.php?file=%{REQUEST_FILENAME}
Order allow,deny
Deny from all
Satisfy All
</files>
Run Code Online (Sandbox Code Playgroud)

但PHP的$ _GET ['file']返回"%{REQUEST_FILENAME}"

.htaccess没有传递名称,它将%{REQUEST_FILENAME}作为字符串传递,而不是传递.

我怎么能让它工作?

谢谢

php .htaccess mod-rewrite

0
推荐指数
1
解决办法
373
查看次数

带有意外发现博客的Apache rewriterule不起作用

我正在使用意外的博客,并希望在apache htaccess文件中进行重写,当在浏览器中打开/ info时它会打开/index.php?/categories/1-Info.

我试过跟随rewriterule:

RewriteRule ^info index.php?/categories/2-Info [L]
Run Code Online (Sandbox Code Playgroud)

它不起作用.当我改变替换成别的东西(如http://www.google.com)它去那里,所以模式应该工作,但它并没有告诉我,我想看到的偶然性类别.当我手动输入时,地址确实有效.

我阅读了十几个带有指南的网页,并使用"http://martinmelin.se/rewrite-rule-tester/"来验证我的重写,但我仍然无法让它工作.不幸的是,我也看不到或设置任何记录.

我如何更改重写?

编辑:

我的.htaccess文件如下所示:

# BEGIN s9y
ErrorDocument 404 /data/script/index.php
DirectoryIndex /data/script/index.php
Options -MultiViews

RewriteEngine On
RewriteBase /data/script/
RewriteRule ^info index.php?/categories/2-Info [L]

<Files *.tpl.php>
    deny from all
</Files>

<Files *.tpl>
    deny from all
</Files>

<Files *.sql>
    deny from all
</Files>

<Files *.inc.php>
    deny from all
</Files>

<Files *.db>
    deny from all
</Files>

# END s9y
Run Code Online (Sandbox Code Playgroud)

apache .htaccess mod-rewrite

0
推荐指数
1
解决办法
126
查看次数

关于url使用查询字符串和表单操作获取重写

请帮助删除其他查询字符串

我在.htaccess中使用此代码

RewriteRule ^ip/(.*)$ /iplookup.php?lookup_ip=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)

它可以工作,但是当尝试在表单中查找其他IP地址时,
它在地址栏中显示如下内容:

"/ip/?lookup_ip=66.249.66.2"
Run Code Online (Sandbox Code Playgroud)

我的表格是

<form action="/ip/" method="get">
<input type="text" value="{$address}" name="lookup_ip" id="lookup_ip">
<input type="submit" value="IP Lookup"/>
</form>
Run Code Online (Sandbox Code Playgroud)

现在可以隐藏"?lookup_ip ="

我想显示/ip/66.249.66.2

我认为我的问题是形式的?

php mod-rewrite url-rewriting

0
推荐指数
1
解决办法
1057
查看次数

Laravel Route不与Wamp合作

正如标题所述,我无法让我的网站重定向.我做了几次尝试,即将失去它.

我的.htaccess文件如下:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php [L]
Run Code Online (Sandbox Code Playgroud)

我将此文件放在www/Laravel/public文件夹以及www目录中

  • mod_rewrite已启用
  • AllowOverride设置为All

我的主机文件如下

127.0.0.1       localhost
Run Code Online (Sandbox Code Playgroud)

这是routes.php中包含的路由代码

Route::get('authors', array('uses'=>'authors@index'));
Run Code Online (Sandbox Code Playgroud)

我有一个名为authors.php的控制器,这里是代码

class Authors_Controller extends Base_Controller {
public $restful = true;
public function get_index () {      
    return View::make('authors.index');}
}
Run Code Online (Sandbox Code Playgroud)

我正在使用Windows 7旗舰版.我要把我的脑袋弄出来.请帮帮我,我很糟糕.

php mod-rewrite routes wamp laravel

0
推荐指数
2
解决办法
2万
查看次数

.htaccess modrewrite到一个文件而不是目录

如何在.htaccess中使用ModRewrite重定向/ admin到admin.php而不显示/ admin目录.

这个:RewriteRule ^ admin $ admin.php当前显示/ admin目录而不是脚本.

我做了一些谷歌搜索但似乎无法获得正确的关键字.提前致谢!

php .htaccess mod-rewrite

0
推荐指数
1
解决办法
77
查看次数

.htaccess REQUEST_URI效果不佳

我试试这个规则

RewriteCond %{REQUEST_URI} !^/dr/he
RewriteCond %{HTTP_HOST} temp.il.gl
RewriteRule ^(.*)$ http://m.il.gl/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)

但是当我尝试temp.il.gl/dr/he/和http://temp.il.gl/dr/

他们都去了m.il.gl我在.htaccess测试员和这个工作尝试它,但是当它插入我的.htaccess时是行不通的.谢谢.

编辑:我也有这样的行:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
Run Code Online (Sandbox Code Playgroud)

编辑:我添加条件:

RewriteCond %{REQUEST_URI} !^/(.*)index.php
Run Code Online (Sandbox Code Playgroud)

之前:

RewriteRule ^(.*)$ http://m.il.gl/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)

现在是工作.谢谢你Yoni

.htaccess mod-rewrite

0
推荐指数
1
解决办法
6166
查看次数

.htaccess重写规则,用于更改查询字符串的路径

我正在研究一个项目,需要一些帮助来重写一些URL ...

我们有一个URL如

http://www.example.com/page/a-c/
Run Code Online (Sandbox Code Playgroud)

我需要它被服务器解释为:

http://www.example.com/file.php?source=a-c
Run Code Online (Sandbox Code Playgroud)

我的.htaccess重写技巧不是那么棒!

.htaccess mod-rewrite

0
推荐指数
1
解决办法
3285
查看次数

标签 统计

mod-rewrite ×10

.htaccess ×7

php ×7

apache ×3

url-rewriting ×2

joomla ×1

laravel ×1

routes ×1

url ×1

wamp ×1