mod-rewrite

rewrite url condition for subfolder

▼魔方 西西 提交于 2019-12-24 00:38:19
问题 I have an htaccess file here /en/.htaccess and i would like to make this condition (which is for the main htacces inside public_html) to work also for the subfolder en RewriteCond %{THE_REQUEST} /events/eventDetails\.php\?id=(.+)&name=(.+)\sHTTP [NC] RewriteRule ^ /events/%1/%2? [L,R] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^events/([^/]+)/([^/]+)/?$ /events/eventDetails.php?id=$1&name=$2 [L] my htaccess starts like this. RewriteEngine on

Getting IIS6 to play nice with WordPress Pretty Permalinks

点点圈 提交于 2019-12-24 00:26:25
问题 I've got a WordPress powered blog that I'm trying to get setup on our IIS6 server and everything works besides the permalink structure which I'm having a big headache with. After googling around/wordpress codex I learned that it's because IIS6 doesn't have the equivalent of Apache's mod_rewrite which is required for this feature to work. So that's where I'm at now. I can't seem to find a functional solution to get the pretty permalinks to work without the "index.php/," anyone have any

PHP code to determine if a user was 301 redirected to my site

别来无恙 提交于 2019-12-24 00:24:55
问题 Is it possible in PHP to know if a user has been 301 redirected to my website? So in myoldsite.com I have a 301 redirect in the .htaccess file to mynewsite.com . Can I place some PHP code in mynewsite.com to recognise when a user has been 301 redirected? I just need this to display a specific message if this is the case. Many thanks for any pointers here :-) 回答1: I believe with 301-redirects the HTTP_REFERER field will contain the original referer: User enters oldsite.com in address bar and

How to create clean url using .htaccess for multiple parameters

时光毁灭记忆、已成空白 提交于 2019-12-24 00:13:27
问题 This is my .htaccess code to rewrite clean url. Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+download\.php\?id=([^\s&]+) [NC] RewriteRule ^ download/%1? [R=301,L] RewriteRule ^download/([^/]+)/?$ download.php?id=$1 [L,QSA] This code works fine for single parameter in url. For example it rewrites www.mysitename.com/download.php?id=123 to www.mysitename.com/download/123 But when I tried to pass multiple

.htaccess rewrite underscores to hypens, strip extension, & remove trailing underscores

和自甴很熟 提交于 2019-12-24 00:09:27
问题 I'm converting my blog from movable type to wordpress.There are several thousand entries, and thankfully I am able to keep (almost) the same permalinks. I know that with some clever .htaccess wizardry, I should be able to redirect my URLs, but I can't for the life of me figure out what the statement(s) should be.I have over 20,000 entries, so redirects on individual pages is not ideal. Here's what I need to do: I have a bunch of URLs like this: http://example.com/posttype/2013/05/04/story

RewriteRule slash optional

烈酒焚心 提交于 2019-12-24 00:08:43
问题 When I put "?" after slash to make it optional, like this: RewriteRule ^user/(.*)/?$ "/index.php?page=view-user&user=$1" But now when I open URL with slash like /user/revolution/ in PHP, $_GET['user'] output "rloveution/" (with slash). So how can I make the trailing slash optional without getting username output with slash ? Thanks. 回答1: You can use negated regex: RewriteRule ^user/([^/]+)/?$ index.php?page=view-user&user=$1 [L,QSA] Or lazy matching: RewriteRule ^user/(.+?)/?$ index.php?page

Dynamic RewriteBase with optional index.php

懵懂的女人 提交于 2019-12-23 23:51:11
问题 I have dynamic base URLs at /us/ , /ca/ and /fr-ca/ . Using the suggested RewriteCond as mentioned here, I was able to get this to work in most cases. The cases that it works are when index.php is not included in the URL, so: /us/path/subpath /us/path2/subpath /us/path/subpath /us/path2/subpath For each of these $_SERVER['BASE'] will return /us/ . If my application plugs in index.php into the URL, BASE is no longer provided. I've tried using RewriteCond $0#%{REQUEST_URI} ^((?:index.php/)?)([^

.htaccess HTTPS Main Domain & Wildcard HTTP Sub-Domains + All Non-WWW

我怕爱的太早我们不能终老 提交于 2019-12-23 23:34:39
问题 There are many similar solutions on Stack Overflow such as htaccess http to https with www. Without redirecting sub domain. What I need, however, is: Main domain HTTPS + NON-WWW Wildcard HTTP for ALL sub-domains instead of adding one after another. I am running a WordPress Multisite website and have no wildcard SSL. I am using the following at the moment: Non-WWW RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} www.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] Non-WWW and Non

Rewriting URL that contains multiple parameters with multi-word strings (with mod_rewrite)

ぐ巨炮叔叔 提交于 2019-12-23 21:17:23
问题 Was trying to rewrite the URL of a page that has multiple parameters and one of the parameters contains multiple words (separated by spaces when submitted). This would be the URL: www.ABCD.com/store/itemsDescr.php?categ=headbands&id=123&name=brown%20with%20black I would like the URL to show like this: www.ABCD.com/store/headbands/123/brown-with-black I tried this, but it did not work: RewriteCond %{QUERY_STRING} ^categ=([^&]+) [NC,OR] RewriteCond %{QUERY_STRING} &categ=([^&]+) [NC]

Using mod-Rewrite with 5 pages (wildcard sub-domain)

与世无争的帅哥 提交于 2019-12-23 20:52:17
问题 Let's say I got 5 pages ( index.php , about.php , portfolio.php , gallery.php , contact.php ). Let's say the id is 1 . The original url is : www.domain.com/folder/index.php?id=1 , www.domain.com/folder/about.php?id=1 and so on... Now, I want to change it to : 1.domain.com/index , 1.domain.com/about , 1.domain.com/portfolio , 1.domain.com/gallery , 1.domain.com/contact Is it possible with mod-rewrite ? And if I'm in the index.php page, whats the <a href="" > that goes to about.php if the mod