mod-rewrite

mod_rewrite with multiple variables

拥有回忆 提交于 2020-01-17 07:42:28
问题 I have a URL like so: http://localhost/deals/?search=fred that redirects to index.cfm?path= When I use mod rewrite the URL parameter becomes path = /deals/?search=fred I currently have RewriteRule /(.*) /index.cfm?path=/$1 [L] How can I split it so I can actually use the URL variable "search"? I am using IIRF rewrite. 回答1: This fixed my problem. thanks RewriteCond %{QUERY_STRING} ^$ RewriteRule ^/(.*)$ /index.cfm?path=$1 [L] RewriteRule ^/(.*)\?(.*)$ /index.cfm?path=$1&$2 [L] 回答2: RewriteRule

.htaccess url rewrite - remove .php remove www. convert ?id=10 to /10

烈酒焚心 提交于 2020-01-17 07:38:19
问题 As the title says, I need a quite complex url rewrite mechanism for a web-app as .htaccess rule. I've searched quite a lot now and tried hundred of different rewrite rules. So, basically this is what I need: User goes to: http://www.site.com/product.php?id=12 Server should redirect to: http://site.com/product/12 Once thing to mention: not all pages do append id's. So I also have: http://www.site.com/some/page.php which then should redirect to: http://site.com/some/page or from http://site.com

Apache RewriteEngine - Rewrite anything that not exists to index.php

为君一笑 提交于 2020-01-17 05:51:05
问题 I'm really struggling now. First of all, i searched on Google and here, and none of the solutions found worked for me. I don't really have much time right now to completely dig into Apache docs for solid understanding of the RewriteEngine(will do later for sure). WHAT I NEED I need to handle special requests from our Google Adwords campaign, which look like this: http://website.com/something/%first_param%/%second_param%/%third_param% In my document root directory, i have index.php where i

htaccess Apache RewriteRule .asp to .php

旧时模样 提交于 2020-01-17 05:00:13
问题 I am trying to use RewriteRule in htaccess to permanently redirect this: http://www.example.com/store/scripts/prodView.asp?idproduct=240 to http://www.example.com/index.php?route=product/product&path=59&product_id=50 I have tried: Options +FollowSymlinks RewriteEngine On RewriteCond %{QUERY_STRING} ^idproduct=240$ [NC] RewriteRule ^store/scripts/prodView.asp$ index.php\?route=product/product\&path\=59\&product_id\=50? [L,NC,R=301] .htaccess is in the root Can anyone suggest where I may be

adding a trailing slash for specific redirection rules

寵の児 提交于 2020-01-17 03:34:07
问题 I'm moving a website to Wordpress and simultaneously changing the convoluted URL structure they had on their old platform. A typical URL looks something like this: /blog/index.php/weblog/comments/post-name But could also look like this: /blog/index.php/weblog/comments/post-name/ (not the inconsistent use of the trailing slash) This is just one example of about a dozen different paths to the same content. As a result I've created a bunch of specific rewrite rules that look something like this:

htaccess redirection with querystring

隐身守侯 提交于 2020-01-17 03:14:27
问题 How can I redirect the following url http://test.com/changefile.php?filename=top-ranked-colleges to http://test.com/top-ranked-colleges.php using htaccess redirection. Anybody please help me. Thanks in advance. 回答1: Try this RewriteCond %{QUERY_STRING} ^filename=(.*)$ RewriteRule .* http://test.com/%1.php? [R=301,L] to change http://test.com/changefile.php?filename=top-ranked-colleges to http://test.com/top-ranked-colleges.php RewriteCond %{REQUEST_URI} ^/(.*).php$ RewriteRule .* http://test

avoiding duplicate urls wih my mod_write

不羁的心 提交于 2020-01-17 02:55:07
问题 At the moment, I have a simple .htaccess that tidies up my page urls, by knocking the .php off the end, or adding it, depending on which way you look at it. Basically, /about.php will become /about. However, this results in my page being accessible on both of those urls. I can just suck it up and use rel=canonical tags but I'd also like to tidy it in my htaccess. Is there a better way (clever rule) to 301 the .php to the none .php version, other than manually specifying each url? Also, do I

Expanding friendly url, mod rewrite

拟墨画扇 提交于 2020-01-17 02:37:35
问题 I am using modx, which is a cms system. It has a friendly url-option and uses a .htaccess like this. # The Friendly URLs part RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] If makes the url look like: mysite.com/about and mysite.com/about/contact I'd like to expand this .htaccess, so I can write myste.com/about/2 without the page 2 actually existing. I'd like to have the ability to access this in a get-variable. Can this be

Clean Urls with mod_rewrite

十年热恋 提交于 2020-01-17 01:34:27
问题 How do I make it so when a user clicks on, http://localhost/jobwehave.co.za/job/1 They are shown the page for http://localhost/jobwehave.co.za/job?=1 But the url still says http://localhost/jobwehave.co.za/job/1 I am using mod_rewrite in an .htaccess file at the root of the site. 回答1: Try this, RewriteRule ^jobwehave.co.za/job/(\d+)$ jobwehave.co.za/job?id=$1 Rick. 回答2: RewriteEngine On RewriteRule /jobwehave.co.za/job/([0-9]+)$ /jobwehave.co.za/job?job=$1 [L,QSA] 来源: https://stackoverflow

Rewriting url to hide index.php and to make query nice

橙三吉。 提交于 2020-01-17 01:11:17
问题 I had developed project with custom MVC architecture. And I am new to Apache world, so I would appreciate help with this matter. On a Web I had found lots of tutorials, but no one like mine interests. I have URL like this: http://knjiskicrv.comoj.com/index.php?page=book&id=1 I would like to be display like this: http://knjiskicrv.comoj.com/book/id/1 Or this: http://knjiskicrv.comoj.com/index.php?page=faq Into this: http://knjiskicrv.comoj.com/faq If there is no page in query (http:/