mod-rewrite

.htaccess doesn't escape question mark on RewriteRule

社会主义新天地 提交于 2021-02-07 20:54:17
问题 I have a website with an old type of Single Sign On. A parent website sends users to my website with a URL like: http://test.instela.fm/index.php?gid=abcd1234&u=thedewil&id=11472 and I want to rewrite it as this: http://test.instela.fm/login/abcd1234/thedewil/11472 I have created a .htaccess file as following: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index.php?gid=(.*)&u=(.*)&id=(.*)$ login/$1/$2/$3 [L] I tried escaping the question mark in the URL

htaccess redirect only if it has value after forward slash

依然范特西╮ 提交于 2021-02-07 20:12:37
问题 I would like to apply the following htaccess rule only if there is a value after the forward slash of /events/ If I visit /events/ (Don't do anything. DO NOT apply the htaccess rule) But if I visit /events/this-can be-anything/ (Apply the htaccess rule below) RewriteRule ^events/(.*) /lp/events/index.php [L] This is obviously not working. 回答1: You need to change your regex pattern (.*) to (.+) to match at least one character after the uri. RewriteRule ^events/(.+)$ /lp/events/index.php [L] 来源

URL Rewrite on a WordPress Page Query String

非 Y 不嫁゛ 提交于 2021-02-07 09:30:00
问题 I have a WordPress site with a custom page comparison that gets a string. Now it takes: mysite.com/phones/compare/?between=samsung-galaxy-note-3-vs-nokia-lumia-730 It needs to be like that: mysite.com/phones/compare/samsung-galaxy-note-3-vs-nokia-lumia-730 I've tried adding code on my site's .htaccess that didn't worked for me and went to WordPress 404 page: RewriteRule ^phones/compare/(.+?)/?$ phones/compare/?between=$1 [NC,L] Also I need to redirect to the new search engine friendly URL too

URL Rewrite on a WordPress Page Query String

耗尽温柔 提交于 2021-02-07 09:29:01
问题 I have a WordPress site with a custom page comparison that gets a string. Now it takes: mysite.com/phones/compare/?between=samsung-galaxy-note-3-vs-nokia-lumia-730 It needs to be like that: mysite.com/phones/compare/samsung-galaxy-note-3-vs-nokia-lumia-730 I've tried adding code on my site's .htaccess that didn't worked for me and went to WordPress 404 page: RewriteRule ^phones/compare/(.+?)/?$ phones/compare/?between=$1 [NC,L] Also I need to redirect to the new search engine friendly URL too

Combining rewrites for non-www/ssl/trailing slash with upper->lowercase in .htaccess

蓝咒 提交于 2021-02-07 09:05:23
问题 So I have a straightforward rewrite to catch non-www URLs, non-SSL urls and urls missing a trailing slash to redirect to SSL, www and trailing slash using: <IfModule mod_rewrite.c> RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(.*)$ [NC] RewriteCond %{HTTP_HOST} ^(.*[^/])$ [NC] RewriteRule (.*\/)$ https://www.tierpoint/$1 [R=301,L] RewriteRule (.*[^/])$ https://www.tierpoint/$1/ [R=301,L] </IfModule> I'd like to add a rewrite to drive uppercase

Combining rewrites for non-www/ssl/trailing slash with upper->lowercase in .htaccess

那年仲夏 提交于 2021-02-07 09:02:28
问题 So I have a straightforward rewrite to catch non-www URLs, non-SSL urls and urls missing a trailing slash to redirect to SSL, www and trailing slash using: <IfModule mod_rewrite.c> RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(.*)$ [NC] RewriteCond %{HTTP_HOST} ^(.*[^/])$ [NC] RewriteRule (.*\/)$ https://www.tierpoint/$1 [R=301,L] RewriteRule (.*[^/])$ https://www.tierpoint/$1/ [R=301,L] </IfModule> I'd like to add a rewrite to drive uppercase

htaccess - Redirect to subfolder without changing browser URL

早过忘川 提交于 2021-02-07 07:56:11
问题 I've a domain that contains a subfolder with the web app structure. I added a .htaccess on my root domain to point the public folder on my subfolder web app. It works fine, but when I type www.example.com the browser URL changes to www.example.com/subfolder/public , but I would like that it doesn't change. This is my .htaccess : RewriteEngine On RewriteRule ^.*$ subfolder/public [NC,L] EDIT This first .htaccess is used to redirect on subfolder/public, where there is an other .htaccess that

htaccess - Redirect to subfolder without changing browser URL

那年仲夏 提交于 2021-02-07 07:55:06
问题 I've a domain that contains a subfolder with the web app structure. I added a .htaccess on my root domain to point the public folder on my subfolder web app. It works fine, but when I type www.example.com the browser URL changes to www.example.com/subfolder/public , but I would like that it doesn't change. This is my .htaccess : RewriteEngine On RewriteRule ^.*$ subfolder/public [NC,L] EDIT This first .htaccess is used to redirect on subfolder/public, where there is an other .htaccess that

Edit HTACCESS file to prevent direct access to a particular file within a particular folder

这一生的挚爱 提交于 2021-02-05 10:01:46
问题 I am trying to prevent direct access to a particular file within a sub-folder. I realize that there are MANY topics depicting similar issues here on this forum. But, mine seems to be a bit awkward........due to my already existing HTACCESS file. Here is the file-path to the file : www.example.com/PRINCIPAL/PROJECTS/my_file.php ( my_file.php is the file I want to restrict from direct access) What I mean is : my_file.php is current accessible only if the user navigates through a particulae

Order of RewriteRules in an htaccess file

做~自己de王妃 提交于 2021-02-05 08:49:27
问题 In an htaccess file, is it necessary that the rewrite rules follow an order? Like, long ones first and shorter ones last or something like that? Or, is it ok to put them in any order. I only have a few rules like the ones below (some 20), but it's all a big mess. RewriteRule ^/?(backend)/(users)/(new|blocked)/([a-z0-9]+)/?$ /blah/users/index.php?type=$2&case=$3&offset=$4 [NC,L] 回答1: Ordering of rewrite rules is very important in .htaccess . You need to put most specific ones at the top and