mod-rewrite

301 Redirecting URLs based on GET variables in .htaccess

一世执手 提交于 2019-12-17 14:28:51
问题 I have a few messy old URLs like... http://www.example.com/bunch.of/unneeded/crap?opendocument&part=1 http://www.example.com/bunch.of/unneeded/crap?opendocument&part=2 ...that I want to redirect to the newer, cleaner form... http://www.example.com/page.php/welcome http://www.example.com/page.php/prices I understand I can redirect one page to another with a simple redirect i.e. Redirect 301 /bunch.of/unneeded/crap http://www.example.com/page.php But the source page doesn't change, only it's

In htaccess, I'd like to replace underscores with hyphens and then redirect the user the new url

强颜欢笑 提交于 2019-12-17 14:00:21
问题 I'd like to redirect any request that contains underscores to the same url, but with hyphens replacing the urls. I've seen a lot of forums suggest I do something like this: (Repeat an incremented version of this rewriteRule up to a gazillion) rewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ http://example.com/$1-$2-$3-$4 [R=301,L] rewriteRule ^([^_]*)_([^_]*)_(.*)$ http://example.com/$1-$2-$3 [R=301,L] rewriteRule ^([^_]*)_(.*)$ http://example.com/$1-$2 [R=301,L] My current solution in php is

URL rewriting for different protocols in .htaccess

早过忘川 提交于 2019-12-17 11:54:43
问题 I need help with url-rewriting in .htaccess. So the issue is about different protocols: https and http. The main purpose of rewriting is to remove "www" from URL, but protocol should stay the same it was before. For example, when I have URL like http ://www.domain.com/request, it should be redirected to the http ://domain.com/request. I resolve it with these rules: RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] But in case, when URL looks

using header() to rewrite filename in URL for dynamic pdf

泄露秘密 提交于 2019-12-17 10:57:48
问题 I have a php script that generates a pdf report. When we go to save the pdf document, the filename that Acrobat suggests is report_pdf, since the php script is named report_pdf.php. I would like to dynamically name the pdf file, so I don't have to type the appropriate name for the report each time that I save it. Asking on a news group, someone suggested this, where filename="July Report.pdf" is the intended name of the report <? header('Content-Type: application/pdf'); header('Content

RewriteRule checking file in rewriten file path exists

此生再无相见时 提交于 2019-12-17 10:44:17
问题 How can you use ModRewrite to check if a cache file exists, and if it does, rewrite to the cache file and otherwise rewrite to a dynamic file. For example I have the following folder structure: pages.php cache/ pages/ 1.html 2.html textToo.html etc. How would you setup the RewriteRules for this so request can be send like this: example.com/pages/1 And if the cache file exists rewrite tot the cache file, and if the cache file does not exists, rewrite to pages.php?p=1 It should be something

.htaccess mod_rewrite > 500 Internal Server Error

别说谁变了你拦得住时间么 提交于 2019-12-17 10:07:02
问题 I am using .htaccess. My original link is: http://example.com/CareerDays/index.php?u_type=admin And I'm trying to make it look like this: http://example.com/v/admin The entire code looks like this: RewriteEngine On RewriteRule ^v/([^/]*)$ /CareerDays/index.php?u_type=$1 [L] And I always get " 500 Internal Server Error " 回答1: When you put configuration directives in a .htaccess file, and you don't get the desired effect, there are a number of things that may be going wrong. Most commonly, the

Request exceeded the limit of 10 internal redirects due to probable configuration error.?

*爱你&永不变心* 提交于 2019-12-17 08:59:09
问题 i have a simple rewrite RewriteRule ^.*$ addnew/$0 however i get the Request exceeded the limit of 10 internal redirects due to probable configuration error. I am trying to rewrite www.mysite.com/ anycharacter into www.mysite.com/addnew/ anycharacter 回答1: Try the folllowing solution, it works for me.I hope this will work for you too. BEFORE DOING ANYTHING - BACKUP YOUR DB! Now, go into wordpress > settings > permalinks Set it to one of the pretty permalink settings like //year/month/' Open a

mod_rewrite urlencoding an already urlencoded query string parameter - any way to disable this?

这一生的挚爱 提交于 2019-12-17 08:56:08
问题 We have some very basic mod_rewrite rules: RewriteRule ^something.swf$ http://www.newdomain.com/something.swf [R=302,L] mod_rewrite seems to do its job, and if the user is accessing: something.swf?param=value , it is redirected correctly to http://www.newdomain.com/something.swf?param=value the problem is in this situation: www.olddomain.com/something.swf?param=URL_ENCODED_VALUE what ends up happening is mod_rewrite takes it upon it self to re-urlencode the query string param so what the user

Best Practice: 301 Redirect HTTP to HTTPS (Standard Domain)

夙愿已清 提交于 2019-12-17 08:32:13
问题 I have been searching for the perfect 301 redirect. But I am finding so many solutions and do not know what’s best. Here is what I want to do http://domain.tld/ → https://domain.tld/ http://www.domain.tld/ → https://domain.tld/ https://www.domain.tld/ → https://domain.tld/ Best practice .htacess? <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%

Best Practice: 301 Redirect HTTP to HTTPS (Standard Domain)

霸气de小男生 提交于 2019-12-17 08:31:09
问题 I have been searching for the perfect 301 redirect. But I am finding so many solutions and do not know what’s best. Here is what I want to do http://domain.tld/ → https://domain.tld/ http://www.domain.tld/ → https://domain.tld/ https://www.domain.tld/ → https://domain.tld/ Best practice .htacess? <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ https://%1%