mod-rewrite

Problem with htaccess URL rewrite rule, query string is being appended to resulting URL

I have a set of rewrite rules that are supposed to process a URL that has anywhere from 1 to 5 parameters. So my URL might look like this: www.site.com/topic1/page1 or www.site.com/topic1/sub1/page1. Here are my rules in this example: RewriteRule ^([^/.]+)/?$ /staticpages/process-selection.php?param1=$1 [E=rwdone:yes,L] RewriteRule ...

mod_rewrite for PHP's "lang?=" for more than one page?

I currently use the follwoing code in my .htaccess file RewriteEngine On RewriteBase / # Redirect languages RewriteRule ^(en|es|zh\-tw|zh\-cn)/?$ index.php?lang=$1 [L] With that code, every time I type for instance, /en at the end of the URL, it redirects me to /?lang=en (loads the the English content from a PHP array): For instance...

.htaccess (Apache mod_rewrite) RewriteRule to match email adress?

Hi! I want to make a rewrite rule from edit/[email protected] to [email protected] : RewriteEngine On RewriteRule ^edit/([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$ edit.php?email=$1 [NC,L] ~ where [\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?) is t...

mod_rewrite works for URLs with en, es but not zh-tw and zh-cn?

My sites are in 4 languages and they are accessed with the following pattern: http://example/index.php?lang=en http://example/index.php?lang=es http://example/index.php?lang=zh-tw http://example/index.php?lang=zh-cn I'm using the following mod_rewrite rule in my .htaccess file: RewriteEngine on RewriteRule ^([a-z]{2}(-[A-Z]{2})?)/(.*...

Which mod_rewrite rule can remove index.php and php extensions (from another existing rule)?

I use the following pattern: http://example/index.php?lang=en http://example/index.php?lang=es http://example/index.php?lang=zh-tw http://example/index.php?lang=zh-cn And I use the following mod_write rule: RewriteEngine on RewriteRule ^([a-z]{2}(-[A-Z]{2})?)/(.*) $3?lang=$1 [L,QSA] With that rule I can use the following URLs which...

Map a second domain to a folder in existing domain with mod_rewrite

I have a jsp application setup with apache/tomcat. My main application is like www.foo.com/main/index.jsp . The content of my main applications is provided by many users. For these users I want to create mini-sites, each containing just the profile of the user and the content he has provided (so it's just a couple of jsp pages for each u...

Using mod_rewrite to serve mobile version of a page

I'm trying to add an optional mobile layout to an existing website. Under certain circumstances, I'd like to be able to serve entirely different content for the mobile version than for the same page on the regular version. If the user visits, say, m.example.com/food/apple.html, he'll see an entirely different page than for example.com/...

.htaccess rule for rewriting a GET URL

Hello, On a website I have a search form with method get. I would like to know if I can rewrite that url to a better looking one. For example, now after I submit the search form I get an url like this: http://www.mywebsite.com/search.php?search_category=0&search_term=Jackson&submit_search= It would be great if I could ma...

How long is too long for an .htaccess file?

I wonder if my .htaccess file is too long/inefficient? I have about 250 lines of rewrite rules like: RewriteRule ^(en|de|fr)/foobar$ ?site=foobar&lang=$1 [L] RewriteRule ^(en|de|fr)/foobar/bar/123$ ?site=foobar&value=bar&othervalue=$2&lang=$1 [L] Is there a way to do it more efficiently? ...

Cakephp pagination problems

Hi all, I am dealing with a very troubling problem trying to setup my cakephp propduction webserver. Due to circumstances out of my control I need to use MSSQL with cakephp, which thankfully is currently provided by default. So I have used an IIS windows server to host my app and am using Halicon Ape to provide rewrite functions. So far ...

How to Detect and Redirect from URL with Anchor Using mod_rewrite/htaccess?

I've seen a number of examples of the opposite, but I'm looking to go from an anchor/hash URL to a non-anchor URL, like so: From: http://old.swfaddress-site.com/#/page/name To: http://new.html-site.com/page/name None of the examples at http://karoshiethos.com/2008/07/25/handling-urlencoded-swfaddress-links-with-mod_rewrite/ have fun...

Display files from another directory with mod_rewrite

I have moved all files from a project that should be accessible from outside to a single public directory - so that instead of blacklisting directories that must remain hidden, I could whitelist accessible ones. However I cannot force apache to rewrite this kind of urls: www.example.com/images/flower.jpg to fetch <DOCUMENT ROOT>/p...

Create an Alias using Apache's mod_rewrite

Hello all! I need to create an alias for one exact page which unfortunately special characters in it. I do have an environment set up so other redirects work fine, but not this one: RewriteRule ^/ow/email.htm?who=Kate%20Jones&direct=True&[email protected]$ http://www.google.com/ow/lalala.htm How should I rewrite th...

avoid dir mod rewrite

i have a rule like this: RewriteRule ^posts/(.*)/([0-9]*)$ viewupdates.php?username=$1&page=$2 [L] and match to: http://site.com/posts/username/1 i need to chante to: http://site.com/username/posts without trailing slash, and if have more pages /posts/1 ...

how can I get my mod_rewrite to work?

I took a look around at other mod_rewrite questions and couldnt come up with an answer, so if anyone would point me to one that I may be duplicating I would appreciate it. Anyways my question is: Why is my mod rewrite not working? I followed like 3 tutorials and spent a while reading forums and previous questions on this site, and could...

A tool to debug and test mod_rewrite (.htaccess) directives

Although being a decent web developer, I and most of my colleagues always struggle with basic tasks when using mod_rewrite. I read the manuals and understood most of it, however most skills I've learned in life are by doing. The trouble is, there's no easy way to debug the configuration. Most of the time if I succeed at configuring the...

Rewriterule Q, example.com/xml/title/ to example.com/xml/index.php?var=title

I have example.com/xml/index.php and I want to access it with this url example.com/xml/title/ and last part would be GET var for index.php and it should show result using that var, what code should I add in my .htaccess file ? Thanks ...

Handling URL rewriting for a multi-language website

Hello, I'm working on a multi-language website and I'm having a little trouble with rewriting URLs. So lets say I want to rewrite URLs for the products page. I must have something like this: http://www.mywebsite.com/products/some-product-name-34.html (for english) http://www.mywebsite.com/produits/some-product-name-34.html (for frenc...

Using mod_rewrite to hide the .py extension of a Python script accessed on a web browser

I want to hide the .py extension of a Python script loaded in a web browser and still have the script run. For example: typing url.dev/basics/pythonscript in the address bar fires pythonscript.py and shows the results in the browser window. The URL url.dev/basics/pythonscript fetches the static file /pythonscript.py The browser...

Migrating from ISAPI Rewrite to Mod_REwrite

I'm currently using ISAPI Rewrite I'd interesting in moving my ColdFusion app to Apache and would therefore like to use MOD_Rewrite. Is this possible? Or do I need to rewrite all the rewrites? ...