天道酬勤,学无止境

.htaccess

用问号替换 & 号(Replac Ampersand with question mark)

问题 出于某种原因,控制器在中间插入的 ? 中使用 & 查询 http 服务器。 如果我用 ? 它工作正常。 有人可以写一个 htaccess 代码来替换吗? 在最后的“/login.php&redirect =”之后到某行“login.php?redirect * ” 回答1 把它放在你的 htaccess 文件中合适的地方 RewriteRule ^(.*)&(.*)$ /$1?$2 [L,QSA,R=301]

2021-10-27 04:09:24    分类:技术分享    .htaccess

Codeigniter url rewrite like subdomain url with .htaccess

Currently my Url is: http://www.domain.co.uk/index.php/city/details/city-name I would like to change it to: http://www.city-name.domain.co.uk/index.php/city/details/city-name or: http://www.city-name.domain.co.uk/city/details/city-name

2021-10-27 04:03:05    分类:问答    .htaccess

将 index 和 index.php 视为同一个文件(Treating index and index.php as the same file)

问题 我正在使用 Apache 2.2.22 和 PHP 5.3.10 处理 PHP 项目,但遇到了 index 和 index.php 被视为同一个文件的问题。 我有一个 admin/index.php,它重定向到 admin/index 以允许我在 .htaccess 中的 mod_rewrite 规则接管并将请求重新路由到自定义框架中。 问题是,当浏览器转到 admin/index 时,它会进入无限重定向循环,因为请求被发送到 admin/index.php,然后重定向到 admin/index 我已经尝试删除 htaccess 文件,看看我的 mod_rewrite 规则是否有问题导致它并且它没有改变任何东西。 它只是无休止地重定向到 admin/index。 我以前从未听说过这种行为,浏览一些 Google 结果并浏览 apache 配置文件并没有显示任何明显的东西。 有没有人以前见过这个并知道如何解决它? 编辑:下面是 index.php 用于重定向到索引的代码。 <?php header("Location: index"); die(); 回答1 这可能是由于启用了 MultiViews: MultiViews的作用如下:如果服务器收到/some/dir/foo的请求,如果/some/dir开启了MultiViews,而/some/dir/foo不存在

2021-10-27 04:01:54    分类:技术分享    php   apache   .htaccess   mod-rewrite   indexing

Redirect any page passing certain variables

I'm putting a search engine on my site, and the search box appears on several different pages. The output looks like this: http://mysite.com/mypage.php?bluepart=search&keywords=dogs&go=Go I'm trying to do an .htaccess mod rewrite to where any page that passes these variables will get redirected to search_results.php. The bluepart=search and go=Go will always be the same, but keywords can be any number or words. Also, some of my pages are .html and some are .php, when I refer to any page that passes the variables.

2021-10-27 03:46:04    分类:问答    php   .htaccess   mod-rewrite

Very simple mod_rewrite questions

1- Does mod_rewrite means that if I make this url: domain.com/ad.php?id=8498292 INTO domain.com/8498292 that all links on my website will have to be changed to the later above? example the link: domain.com/ad.php?id=8498292 wont work now, unless I replace it with domain.com/8498292 ? Or will the server know that they are the same still? 2- Will the rewritten link appear rewritten in the browsers adress bars also, so if I enter domain.com/ad.php?id=8498292 it will actually appear as domain.com/8498292 in the adress bar itself? 3- Will images and all other related links and material on the page

2021-10-27 03:22:02    分类:问答    php   html   linux   apache   .htaccess

use .htaccess redirection to connect to vpn

I am trying to connect to a VPN connection using an automatic redirection via a .htaccess redirection, so the vpn setup is a bit more user-friendly using an url instead of an ip address. The thing is that, when using the ip directly, all works smoothly. However, using .htaccess which redirects to my public IP address throws an Error 868. My .htaccess is very basic - all I do is forward the input to the public IP without any filter: RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ my.public.ip.address$1 The reason I am trying this is that I have successfully setup VPN via sub-domain

2021-10-27 02:45:56    分类:问答    .htaccess   vpn   url-redirection

Test htaccess code offline

I wanted to test my website offline, but this is my problem: How can I test RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] offline?

2021-10-27 02:05:23    分类:问答    .htaccess   offline

Problems with RewriteMap MapType dbd

Continuing from another discussion here: MySQL + htaccess mod_rewrite? Where I was asked to start another question. I added this to my httpd.conf file: DBDriver mysql DBDParams "host=*****,user=*****,pass=*****,dbname=*****" RewriteEngine On RewriteMap hrci "dbd:SELECT title FROM challenges WHERE id = %s" When I tried to restart Apache I got this error: RewriteMap: file for map hrci not found:/dh/apache2/apache2-ps54462/dbd:SELECT title FROM challenges WHERE id = %s It looks like it's completely ignoring the dbd part and trying to read the whole thing as a file name. I really don't know what I

2021-10-27 01:57:39    分类:问答    mysql   .htaccess   mod-rewrite   rewritemap

Symfony 2 problems with subdomain

I think i have a problem with htaccess. I have a subdomain which redirects to a folder such as subdomain.domain.com --> home/subdomain The problem is that if i write subdomain.domain.com is not redirected to app.php, if i write subdomain.domain.com/app.php it works. On the other side if i write domain.com/subdomain/web (supossing that this is the route to the app) there is no need to write app.php. So it works with both: domain.com/subdomain/web/ and domain.com/subdomain/web/app.php I have the following htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f

2021-10-27 01:49:41    分类:问答    php   .htaccess   symfony

Why does this .htaccess RewriteRule that includes a '#' fail?

Goal: Match URL and rewrite it to a query string. Problem: Looks like the "#" (and everything after it) in the replacement string is being ignored. Here's what I have: RewriteEngine On RewriteRule ^([^\.]+)$ $1.html [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+) web2.html#list?d=$1&n=$2 [L,NE] This gets to web2.html but the url parameters (d= & n=) are never applied. The goal is to allow a url like: somewehere.com/55c26838e4b087b032b432c4/1/ to trigger a query like this: somewehere.com/web2#list?d=54668494e4b09ffed41ff167&n=1

2021-10-27 01:39:44    分类:问答    .htaccess   mod-rewrite