mod-rewrite

Needs some help with an apache mod-rewrite issue

浪尽此生 提交于 2019-12-20 04:36:47
问题 I've modified my .htaccess file to have the following statement RewriteCond $1 !^index.php$ RewriteRule ^/?([^/]+)$ index.php?c=home&m=details&seo=$1 [L,NS] This allows me to use product URL's like this: http://domain.com/product_name However, when trying to access a file at the same level as index.php, it always calls the RewriteRule above and errors out. I need to be able to access files like below, but each URL currently attempts to load index.php. http://domain.com/about.htm http://domain

.htaccess rewrite rule for forcefully redirect https to http

℡╲_俬逩灬. 提交于 2019-12-20 04:24:37
问题 I have a primary domain https://www.domain.com or https://domain.com and a wildcard DNS like https://domain.com/index.php?name=abcd redirect on forcefully http://abcd.domain.com but I have another problem my login page is https://domain.com/login.php?name=abcd and I want result like forcefully http://domain.com/login.php?name=abcd but it cannot redirect on HTTP. RewriteEngine On #match either the www subdomain or no subdomain RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain\.com)$ #which request

Mod Rewrite - is there a faster way?

天大地大妈咪最大 提交于 2019-12-20 04:24:34
问题 im building a site with lots of parameters. At the moment i'm using this Code in my .htaccess file: Options +FollowSymLinks RewriteEngine on RewriteBase /epo RewriteRule (.*)/(.*)/(.*)/(.*)/(.*)/$ index.php?section=$1&content=$2&site=$3&param=$4&param2=$5 [QSA] RewriteRule (.*)/(.*)/(.*)/(.*)/$ index.php?section=$1&content=$2&site=$3&subsite=$4 [QSA] RewriteRule (.*)/(.*)/(.*)/$ index.php?section=$1&content=$2&site=$3 [QSA] RewriteRule (.*)/(.*)/$ index.php?section=$1&content=$2 [QSA]

Can mod_rewrite preserve a double slash?

南笙酒味 提交于 2019-12-20 04:16:08
问题 Im just learning mod_rewrite and regex stuff, and what I'm trying to do is pass variables of any name, with any number of variables and values, into a script and have them forwarded to a different script. here is what I have so far: RewriteEngine on RewriteRule ^script\$(.*[\])? anotherscript?ip=%{REMOTE_ADDR}&$1 [L] That all seems to work except that one of the parameters I'm passing is a URL and the // after http:// always gets stripped down to one slash. for example, I do script$url=http:/

Phar: re-use .htaccess-defined rewrite rules

徘徊边缘 提交于 2019-12-20 04:13:03
问题 My PHP project has a dozen URL rewriting rules listed in .htaccess. Now I want to provide the application as a .phar file and thus need to re-implement the rewrite rules the rewrite function that can be passed to Phar::webPhar() as 4th parameter. Is there a way to re-use the .htaccess rewrite rules in my php code without implementing them in PHP directly? Some library/extension/code that just "interprets" them? 回答1: Before packaging up the .phar file, I generate a PHP array of regex pattern

RewriteRule - html broken - Like missing css

我们两清 提交于 2019-12-20 04:12:58
问题 I have problem with this rule: RewriteRule ^([^/]+)/(\d+)$ more.php?books=$1&tags=$2 [L] After this rule everything works but page is displayed incorrectly. Like missing css. Thanks in advance 回答1: This might happen, when you have a relative URL to your CSS files. If you access the URL /book-name/2 and have a link to css/style.css , for example, the browser will resolve this to /book-name/css/style.css . Change your CSS links to absolute URLs, like /css/style.css , and you should be fine. 来源:

.htaccess file all others whoa re not some browser

蓝咒 提交于 2019-12-20 04:06:50
问题 I have this code: RewriteCond %{HTTP_USER_AGENT} (navigator) [NC] RewriteRule ^newfolder/(.*)$ /index.html [L,NC] I em intresting in first line - How to put ALL OTHERS BROWSERS WHO ARE NOT NAVIGATOR? Somethung like: RewriteCond %{HTTP_USER_AGENT} (navigator) [NC] ALL OTHERS WHO ARE NOT NAVIGATOR! 回答1: You can use negation in RewriteCond : RewriteCond %{HTTP_USER_AGENT} !(opera|navigator|safari) RewriteRule ^newfolder/(.*)$ /index.html [L,NC] PS; Take note of RewriteCond %{HTTP_USER_AGENT}

htaccess redirect fails to redirect when directory exists

孤者浪人 提交于 2019-12-20 03:53:06
问题 For making friendly URLs, Following is the htaccess code applied: RewriteEngine On RewriteCond %{THE_REQUEST} /.+?\.php[\s?] [NC] RewriteRule ^ - [F] RewriteRule ^([^/\.]+)$ index.php?id1=$1 [NC,L,QSA] RewriteRule ^([^/\.]+)/([^/\.]+)$ index.php?id1=$1&id2=$2 [NC,L,QSA] This now works for: mydomain.com/pages to mydomain.com/index.php?id1=pages mydomain.com/pages/xyz to mydomain.com/index.php?id1=pages&id2=xyz also, when I enter mydomain.com/index.php?id1=pages&id2=xyz manually in the URL, it

Redirect and rewrite with mod_rewrite

旧时模样 提交于 2019-12-20 03:50:11
问题 After asking this question: Clean URLs for search query? I tried something with mod_rewrite: RewriteCond %{QUERY_STRING} ^s=([a-z]+)$ [NC] RewriteRule / /s/$1? [NC,R=301,L] RewriteRule ^s/([a-z]+)$ /?s=$1 [NC,L] What's the goal? Redirect http://example.com/?s=query to http://example.com/s/query Rewrite http://example.com/s/query to http://example.com/?s=query This looks like double work but if you take a good look you see what I try to accomplish: Redirect any search querystring to a cleaner

Removing trailing slashes with mod rewrite?

冷暖自知 提交于 2019-12-20 03:49:09
问题 This relates to my previous question (which can be viewed here). I'd like to be able to remove the trailing slash from the URL so that it doesn't mess up certain areas of my site. The .htaccess code is here: # -s = File Exists RewriteCond %{REQUEST_FILENAME} -s [OR] # -l = Is a SymLink RewriteCond %{REQUEST_FILENAME} -l [OR] # -d = Is a Directory RewriteCond %{REQUEST_FILENAME} -d # if we match any of the above conditions - serve the file. RewriteRule ^.*$ - [NC,L] # only allows '.' in the