mod-rewrite

Mod Rewrite - Redirecting based on having GET parameters or not

I want to redirect these URLs: http://example.com/search to http://example.com/?page=search http://example.com/search?q=keyword to http://example.com/?page=search&q=keyword I am trying to use this in .htaccess but doesn't work: RewriteRule ^search$ ?page=search [nc] RewriteRule ^search\?(.*)$ ?page=search&$1 [nc] What am I doi...

Mod_Rewrite category directory

Hello, I would like to forward categories to index.php from root directory; Here is the example; domain.com/en/category1/category2/ ---> index.php?lang=en&cat1=category1&cat2=category2 How can I do that? ...

Clean URLs for static HTML files with .htaccess and mod_rewrite

Hello. mod_rewrite always baffles me... can anyone tell me the rules I need to get the following clean URLs? Desired URL on the left, real URL on the right. /our-work/ => /our-work.html /our-work/some-project/ => /our-work/some-project.html /contact/ => /contact.html As you can see, I want to force trailing slashes on all URLs too. T...

.htaccess rewrite include all url variables

I have a url that is rewritten using htaccess. The problem I'm running into is that some pages have a couple php get variables that aren't being included in the rewrite. Here is the code: Options +FollowSymlinks RewriteEngine on RewriteOptions MaxRedirects=10 RewriteRule ^(.*)$ http://www.domain.org/$1?l=es [P,R=301,L] Is it possibl...

the '.htaccess' file won't work on my apache server

Hi, I have an Apache server installed on my windows machine using XAMPP. Now I'm trying to use a premade .htaccess file for one of my projects, but it doesn't seem to be seeing it. The project just totally ignores it, even though I've enabled mod_rewrite. Any idea how I can troubleshoot this? I can't fix it if it just doesn't work and ...

htaccess mod rewrite changes http://www to http:/www

I want to replace calls like this: www.mysite.com/sub/file.php?param1=x&param2=http://www.someurl.com with: www.mysite.com/sub/param1/param2 Param 1 is an integer number Param 2 is a url I wrote this rewrite rule in htaccess: RewriteCond %{REQUEST_URI} \/sub\/ RewriteRule sub\/([0-9]+)\/(.*)$ sub\/file.php?param1=$2&param2=$1 [L]...

rewrite URL for PUT request

Hi, I changed the way my URL are working on my server. It is now www.myserver.com/service instead of www.myserver.com/test/service I have added a RedirectMatch 301 to my Apache conf file to redirect any access to www.myserver.com/test to www.myserver.com/. I am receiving file to this server via an HTTP PUT at this URL for example : ww...

htaccess redirect *.domain.com to www.domain.com/index.php

I want to redirect a user to www.domain.com/index.php if they type in either: domain.com or www.domain.com. I'm clueless about htaccess. Here's what I found but I don't know how to write an OR statement for the www. redirect RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\.com RewriteRule (.*) http://www.domain.com/index.php$1 [R=301]...

RewriteRule question

Is there any way i can use RewriteRule to show these links: /articles_history.php /articles_geography.php as /articles/history.html /articles/geography.html I created a .htacesss file on my root directory and would like to know if the above is possible by placing some kind of code in the .htaccess file. ...

How do I use POST with htaccess rewriterule?

I have a rewriterule in my htaccess file that looks like this: RewriteRule ^Signup$ /dst2/signup.php I would like to use POST instead of GET for the data that gets passed by this form. The rule above, however, sends the data as a GET. Is there a way to use a POST with a rewriterule? G-Man ...

mod_rewrite with question marks and ampersands (with PHP)

I have a PHP-based web app that I'm trying to apply Apache's mod_rewrite to. Original URLs are of the form: http://example.com/index.php?page=home&x=5 And I'd like to transform these into: http://example.com/home?x=5 Note that while rewriting the page name, I'm also effectively "moving" the question mark. When I try to do thi...

Subdomain URL Rewriting and Web Apps

So a lot of web apps have the customer choose their own subdomain, ie mycompany.webapp.com Presumably, every subdomain works off the same set of files and the unique subdomain is perhaps stored as a session object. So how does the URL rewriting work? If someone goes to mycompany.webapp.com, you have to rewrite their unique address to a...

Is there a major downside to using .htaccess files in your svn/git repository?

If our .htaccess files are purely for mod rewrites, is there a security / development downside to committing .htaccess files alongside other files in your repository? For various reasons (our SEO optimisers like to add pretty urls as new promotions occur, etc) we need a fair few rewrite rules inside these files. Would I be better off pu...

remove multiple trailing slashes mod_rewrite

I know this question was asked a number of times on this site alone, but browsing through the relevant posts I couldn't find a solution. Trying to remove multiple trailing slashes after domain. The following mod_rewrite expressions seem to work for URLs such as http://www.domain.com//path1///path2////, but do not work for domain// Direc...

Subdomain to folder htaccess

I am trying to point sub.domain.com to domain.com/app/*sub, but the farthest I can get is making it a redirection and I do not want it to redirect. Here is what I have, it works but it redirects it instead of staying on the subdomain, which is what I want. RewriteCond %{HTTP_HOST} ^(.*).example.com RewriteCond %{HTTP_HOST} !^www.exampl...

User chooses own subdomain, so URL rewriting?

I know we set up the DNS so all subdomains point to our server and configure IIS to respond to every subdomain. I'm looking to know how to rewrite the URL so that each account uses the same set of files and they still browse at that subdomain. Our application isn't written in MVC, so I cant rewrite abc.webapp.com to webapp.com/abc/ At ...

redirect external subdomain traffic

Hi, I have apache installed on one of my server on two different ports, all http requests are handled by the apache on the default (80). Now I have a subdomain for a domain and I want the request for the sub domain to be handled by the apache on the other port (10024). I've tried using RewriteEngine On RewriteCond %{HTTP_REFERER} ^sub...

url rewriting help

i am using url rewriting like RewriteRule ^mobiles/(.*)$ /mobile_rating.php?alias=$1 [L,B] which works well for me like /mobiles/nokia70 /mobile_rating.php?alias=nokia70 i need a small change like /mobiles/nokia70 /mobile_rating.php?alias=nokia70&product=mobiles i mean to say like the mobiles in url must be changed to produ...

mod_rewrite regex help

HI guys. Im using mod_rewrite to do some redirects on a web site. I want to be able to do the following mySite.com/ -> Goto Home mySite.com/foo -> Goto redirect.php and redirect acordingly. My redirect rule was RewriteRule (^\w*$) redirect.php?url=$1 [NC] But im oviously missing something because when I go tomySite.com/ I get sent t...

Mod Rewrite: Handling two Get Variables

Hello all, How can I edit this url rewrite to include a further get variable being appended to the URL? I have tried a few attemps but I always get a 500 internal server error! I have added comments to show what I am trying to achieve. # /view.php?user=h5k6&page=1 externally to /h5k6/1 # Some times the page get variable will not exist...