mod-rewrite

hostgator: wildcard subdomain mapping to URL

帅比萌擦擦* 提交于 2019-12-12 03:16:11
问题 I have been struggling with this problem on hostgator shared hosting server for the past 3 hours. This is the problem in the simplest. This is the mapping i want to happen: subdomain.domain.com --> www.domain.com/test.php?user=subdomain but for some reason whenever i enter "subdomain.domain.com" the redirection doesn't happen and even the URL doesn't change in my browser. And I see test.php file listed on loaded page (because The only files i have on server are .htaccess and test.php). This

Is it possible to make ineffective a character in regex

百般思念 提交于 2019-12-12 03:14:09
问题 I'm trying to write wordpress pretty permalinks regex. I have following urls. I need 2 matches, 1st : last word between / and / before get/ 2nd : string which is start with get/ Url's may be like these http://localhost/akasia/yacht-technical-services/yacht-crew/get/gulets/for/sale/ Here I need "yacht-crew" and "get/gulets/for/sale/" http://localhost/akasia/testimonials/get/motoryachts/for/sale/ here I need "testimonials" and get/motoryachts/for/sale/ http://localhost/akasia/may/be/lots/of

Apache mod_rewrite complex URL regex

偶尔善良 提交于 2019-12-12 03:13:44
问题 i want to make a beautiful URL from a URL like this: http://example1.com/cimage/webroot/img.php?src=http://example.com/img1.jpg&w=600&h=800&q=60&sharpen&crop-to-fit So the result URL must be somthing like this: http://example1.com/cimage/webroot/img.php/http://example2.com/img1.jpg/600*800/60/sharpen/crop-to-fit Now my problem create a regex for use in apache mod_rewrite. help me please. thanks... 回答1: Based on the discussion in the comments, this is the solution: RewriteRule ^img.php/(https?

rewrite my url, remove query string and make new pretty url

半城伤御伤魂 提交于 2019-12-12 03:12:39
问题 I want to rewrite my url from http://website.com/preview.php?id=puzzled to http://website.com/cv/puzzled and from http://website.com/resume.php?id=puzzled to http://website.com/puzzled ... but seems i am failed to get this result. Options +FollowSymLinks RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([0-9a-zA-Z-]+) /resume.php?id=$1 [QSA,L] RewriteRule ^cv/([0-9a-zA-Z-]+) /preview.php?id=$1 [QSA,L] 回答1: You can use these rules: Options +FollowSymLinks RewriteEngine on

Where's the error in my .htaccess RewriteRule Regexp?

夙愿已清 提交于 2019-12-12 03:08:44
问题 I want this url http://www.test.racebooking.net/rankings/classifica.html to point to http://www.test.racebooking.net/rankings.php thus, i wrote this rule in my .htaccess file RewriteRule ^rankings\/[a-zA-Z0-9\-]+\.html$ /rankings.php I really can't figure out why, when i type the first url, i get a 404 error msg. RewriteEngine is on. /rankings.php exists. Moreover, I have another RewriteRule, much more complex, which i wrote, which is working like charm. classifica.html doesn't exist. I'm

Htaccess rule to make urls like this ?page=1 look like /page/1 in Codeigniter

六月ゝ 毕业季﹏ 提交于 2019-12-12 03:08:31
问题 This is how my urls currently look: http://mysite.com/?page=1 How can I make this work?: http://mysite.com/page/1 There is a post on StackOverflow that asks the same question. But the accepted solution isn't working for me. Because I am using Codeigniter and my page results in a 404 perhaps because since the url pattern of a CI site is: domain/controller/method The system is assuming that I am requesting a controller called "page" and a method called "1" both of which of course doesn't exist.

How the Environment tag E works in .htaccess mod rewrite

人走茶凉 提交于 2019-12-12 03:03:00
问题 I have the following rules in a htaccess file RewriteEngine On RewriteRule mytest.php test.php RewriteCond %{QUERY_STRING} !done RewriteRule (.*) $1?done [E=TEST:itworks] The file test.php is simply <?php echo "TEST = " . getenv('TEST'); ?> When I enter the request uri test.php, the environment variable TEST is defined and it echoes 'Test = itworks'. However, when I enter the request uri mytest.php, it also goes to test.php, but the environment variable TEST is not defined and it echoes 'Test

htaccess remove query string

怎甘沉沦 提交于 2019-12-12 02:59:43
问题 I'm not too familiar with regular expressions and I'm having trouble achieving what I want. The website I'm working on used to have a wordpress blog on it and there are existing links on the internet pointing to http://www.website.com/?p=(random number). The current code I have right now doesn't seem to work: RewriteCond %{QUERY_STRING} p=(.*) RewriteRule http://www.website.com/ [R=301,L] In fact if there is a way to remove any kind of query string for the index page, that would be even

htaccess force www and remove index.php

帅比萌擦擦* 提交于 2019-12-12 02:57:50
问题 Currently I have htaccess which removes index.php from URL, its working fine. But now I want to force url to start with www . My current code: DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] I tried following code, but its not working: DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js

Removing multiple slashes with htaccess

独自空忆成欢 提交于 2019-12-12 02:55:24
问题 I know how to do it with PHP, how to replace multiple slashes from URL to only one, for example: http://example.com/uri1////////uri2/uri4 replace to: http://example.com/uri1/uri2/uri4 etc. How do to it with htaccess? 回答1: Place this code in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*) RewriteRule ^ %1/%2 [R=302,L,NE] 来源: https://stackoverflow.com/questions/20353719/removing-multiple-slashes-with-htaccess