mod-rewrite

Apache Mod Rewrite - Replace : character with another

痞子三分冷 提交于 2019-12-19 04:04:23
问题 I'm trying to rewrite all URL's that contain a ':' in it to another character. http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words Example: http://example.com/some_interesting:info http://example.com/some_interesting_info http://example.com/some:interesting:info http://example.com/some:interesting_info would all point to this file some_interesting_info How can I do this? EDIT: Did more testing this works RewriteRule ^(.*)_(.*) $1$2 [L] RewriteRule ^(.*)\_+(.*) $1$2 [L] test

Php handling vs Apache RewriteRules and RegExp: which one is quicker?

谁都会走 提交于 2019-12-19 03:58:56
问题 I've already read this but it doesn't answer to my question. Here's my scenario: I've been working on my own framework which I'm proud of (multilanguage, templating, and so on). But I had to face one problem: the multilanguage and template handling was done in Php. 800 lines of code, analyze host to see where to look to read the templates and so on. It was messy and I'm pretty sure it wasn't efficient though I didn't test its efficiency . It was dealing with lot of array ( array_push() ,

Redirecting Subdirectory to Subdomain with htaccess

你。 提交于 2019-12-19 03:41:28
问题 I'm relatively new to using .htaccess, and have never done any coding besides what I've read online. I'm using Bluehost, and I'd like to redirect my blog subdirectory to a subdomain. Example: I'd like to redirect www.example.com/blog to blog.example.com. I already have code in place to always add www. to the beginning of my blog address in the root folder, but I don't know how to accomplish the above redirect by using code in .htaccess. Any help would be appreciated! 回答1: A lot of web hosts

Redirecting Subdirectory to Subdomain with htaccess

。_饼干妹妹 提交于 2019-12-19 03:41:17
问题 I'm relatively new to using .htaccess, and have never done any coding besides what I've read online. I'm using Bluehost, and I'd like to redirect my blog subdirectory to a subdomain. Example: I'd like to redirect www.example.com/blog to blog.example.com. I already have code in place to always add www. to the beginning of my blog address in the root folder, but I don't know how to accomplish the above redirect by using code in .htaccess. Any help would be appreciated! 回答1: A lot of web hosts

What's wrong with my RewriteRule via .htaccess? (Why does it need RewriteBase?)

﹥>﹥吖頭↗ 提交于 2019-12-19 03:02:06
问题 rewriteengine on rewriterule ^/a/b$ ^/c$ not working,but rewriteengine on rewritebase / rewriterule ^a/b$ ^c$ works. 回答1: It's probably not the RewriteBase that makes the rule work so much as the leading slash. Also, the second argument to RewriteRule isn't a regular expression. Instead, try: RewriteRule ^/?a/b$ c When applying a RewriteRule from .htaccess, the leading slash will be stripped from the URL, which will cause the pattern to fail if you include it. By starting a pattern with "^/?"

Extensionless URL trailing slash redirect

99封情书 提交于 2019-12-18 18:08:54
问题 I've tested the code below on several domains hosted on Dreamhost and it works—except on newer domains I've added within the last year. RewriteEngine on #unless directory, remove trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ $1 [R=301,L] #redirect external .php requests to extensionless url RewriteCond %{THE_REQUEST} ^(.*)\.php([#?][^\ ]*)?\ HTTP/ RewriteRule ^(.*)\.php$ $1 [R=301,L] #resolve .php file for extensionless php urls RewriteCond %{REQUEST_FILENAME} !-d

Remove/Redirect index.php from url to prevent duplicate urls

大兔子大兔子 提交于 2019-12-18 17:57:22
问题 Please read the question carefully before marking as duplicate. We all know, that using in .htaccess : RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] we can redirect all traffic to index.php so we can create friendly urls and have one front controller. Although the question is connected to mod_rewrite the problem is described for Laravel. The following .htaccess comes by default with Laravel 4 and it works fine: <IfModule mod_rewrite.c>

blocking semalt referrers with htaccess rules

醉酒当歌 提交于 2019-12-18 17:38:06
问题 I have implemented the following code to htaccess but are still seeing referrers from semalt, such as: 74.semalt.com 89.semalt.com The code: # Block visits from semalt.com RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*semalt\.com [NC] RewriteRule .* - [F] Any idea how these referrers are bypassing this rule (which I found online) and how I can fully prevent them? 回答1: Your code looks good, syntax checks out ok! I used these mod_rewrite methods: RewriteCond %{HTTP_REFERER}

simple .htaccess redirect : how to redirect with parameters?

痴心易碎 提交于 2019-12-18 17:05:34
问题 My goal is simply to redirect: /jsn.php?parameters to http://www.site2.com/jsn.php?parameters I tried with Redirect permanent /jsn.php(.)* http://www.site2.com/jsn.php$1 回答1: Query string parameters are automatically passed, you simply want to do this: Redirect permanent /jsn.php http://www.site2.com/jsn.php The (.)* doesn't work with the Redirect directive, you were probably thinking of RedirectMatch , but either way, you don't need it. And also (.)* should be (.*) , otherwise the $1

Problem detecting empty REQUEST_URI with Apache mod_rewrite

♀尐吖头ヾ 提交于 2019-12-18 16:52:07
问题 I am running Apache witha redirect rule like this: RewriteCond %{HTTP_HOST} ^1st-domain\.com RewriteRule ^(.*)$ http://2nd-domain.com$1 [R=permanent,L] This successfully redirects http://1st-domain.com to http://2nd-domain.com However, when the REQUEST_URI is empty, I want to redirect to a third domain. RewriteCond %{HTTP_HOST} ^1st-domain\.com$ RewriteCond %{QUERY_STRING} ^$ RewriteRule ^(.*)$ http://3rd-domain.com$1 [R=permanent,L] But this does not work and instead redirects to 2nd-domain