Tagged Questions

mod_rewrite is a URL rewriting module for the Apache web server. It is commonly used for so-called "pretty" URLs because of its ability to redirect on the server side (transparent to clients and their browsers), but also provides the power and flexibility to perform various request handling tasks ...

learn more… | top users | synonyms

0
votes
1answer
219 views

Mod RewriteRule not working on all URL's

this is my .htaccess Options +FollowSymLinks RewriteRule ^(.*)wp-content/uploads/(.*) $1watermark.php?src=wp-content/uploads/$2 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On ...
3
votes
1answer
133 views

Can I get IIS to treat some .shtml files as .php files?

I want to be able to get IIS to interpret SHTML files (only in a specific directory) as PHP, and interpret the rest as SHTML. If so, then how?
1
vote
1answer
1k views

mod_rewrite causing too many redirects

The .htaccess we have in our document_root directory is as follows: RewriteEngine on RewriteRule ^posts/1/first-post-title$ /posts/1.html [L] RewriteCond %{REQUEST_URI} ^/posts/1 RewriteCond ...
2
votes
2answers
63 views

I want to redirect anyHOST.anyTLD to www.anyHOST.anyTLD

I'm trying to find a generic enough modrewrite rule that will acomplish following: Redirect anyHost.anyTld to www.anyHost.anyTld Not mess with any other subdomains, for examle other.anyHost.anyTLD ...
1
vote
1answer
252 views

301 Redirect are these URLs equivalent?

I want to redirect an entire duplicate directory to the same files in the directory above the dup_folder. Redirect Code in .htaccess: Redirect 301 /dup_folder/ http://www.example.biz/ It redirects ...
1
vote
1answer
381 views

Infinite redirect loop in cPanel-purchased script

I am installing a script (that I bought on cPanel) in the root directory of my web site. When I try to install it, it gives me an error. I found that it starts an infinite URL redirect loop containing ...
1
vote
1answer
6k views

How to setup mod_rewrite/htaccess to do url masking and forwarding to a subdirectory?

Its been about three years since I've played with apache and php(I've been using thin and nignx ;). So I've forgotten how to setup a mod_rewrite directive to forward all http requests from root to the ...
0
votes
2answers
957 views

Apache mod_rewrite rule to convert URL of page, keeping parameters same

I sent out a link in an email that had a typo in the URL. I need to make a quick change for tracking purposes so that any incoming hits to the URL are instead parsed to another URL. From the link ...
3
votes
2answers
432 views

RewriteRule not working for certain URLs

There are a few domains pointing towards the same server, and of course I need them all redirect to only one of them. Redirects work, but only for certain URLs. What works: http://www.domain.com, ...
2
votes
1answer
153 views

Apache mod_rewrite problem

I try to use Apache mod_rewrite to redirect some pages on my customer's website to the homepage. The .htaccess file is the following: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / ...
1
vote
3answers
117 views

mod_rewrite: rewriting http://$SOMETHING.app.example.com/ to http://www.example.com/app/$SOMETHING

I'm trying to make http://$SOMETHING.app.example.com/ transparently rewrite to http://www.example.com/app/$SOMETHING. The config below is giving me a 404 and I'm not sure why. ServerName ...
1
vote
1answer
2k views

Setting Content Type with mod_rewrite

I have the following mod_rewrite rule: RewriteRule ^/yui-3.3/yui_config.js$ /web/yui/yui_config.js [R] when looking at the network traffic with Firebug and Chrome I noticed that ...
1
vote
1answer
56 views

mod_rewrite change . to -

I'm moving my site and the URL structure has changed because of the new CMS. The urls would be similar to /my.products.htm on the new site we are changing the URLs to this /my-products is their a way ...
1
vote
1answer
2k views

mod_rewrite with Apache -> mod_jk -> tomcat

Related to some of my earlier questions. I now have a setup I quite like; Apache httpd listening on port 80 accepting http and https connections. Several Tomcat instances running on several AJP ...
3
votes
4answers
2k views

How to create .htaccess to block access to a subdirectory that hosts a separate domain

So I am pretty noob at with creating code in .htaccess, but I know it is what I need to accomplish a pretty simple task. So here is what I want to do. I have a main domain, (me.com), and I am hosting ...
1
vote
1answer
129 views

How do I get rid of the “www” with mod_rewrite?

I want to get rid of the "www" in front of my domain, and I'm trying the following, but it's not working: RewriteEngine On RewriteCond %{HTTP_POST} ^www\.example\.com [NC] RewriteRule ^/(.*) ...
2
votes
2answers
1k views

How can I redirect everything but the index as 410?

Our site shut down and we need to give a 410 redirect to the users. We have a small one-page replacement site set up in the same domain and a custom 410 error page. We'd like to have it so that all ...
3
votes
2answers
545 views

How do I redirect an English language URL to an Arabic language URL?

I have a link that's currently formatted like this: http://site.com/news/view/1.html I want to it redirect it to: http://site.com/خبر/عنوان-الخبر where خبر is equal to news and عنوان-الخبر is ...
0
votes
1answer
267 views

How to block access to a sub-site with mod_rewrite?

Let's say I have the sites siteA.com and siteB.com. They are hosted such that siteB.com actually points to siteA.com/siteB. How can I block someone from visiting siteA.com/siteB using mod_rewrite? ...
2
votes
3answers
293 views

Mod Rewrite question

Is there a way to rewrite http://localhost/embed/player.swf?file=http://www.youtube.com/watch?v=7yKDhm4_-90 to something smaller? or is there a way to change this into ...
1
vote
2answers
99 views

rewrite on urls to add “/”

I know how to rewrite urls to redirect to a page. When the "/" is not at the end of www.DomainName.com/user/myUserName the redirect works: RewriteRule /$ /user/index.php When I write RewriteBase / ...
1
vote
2answers
632 views

.htaccess rules to rewrite URLs to front end page?

I am adding a new application to my site at example.com/app. I want views at that URL to always open myapp.php. E.g. example.com/app -> example.com/app/myapp.php and example.com/app/ -> ...
0
votes
2answers
170 views

Help with Apache mod_rewrite rules

I want to change some legacy URL's like this: /modules.php?name=News&file=article&sid=600 to this: /news/story/600/ This is what I have tried: RewriteEngine on RewriteCond ...
1
vote
1answer
442 views

Regex Needed to allow mod-rewrite rule to work either with or without trailing slash?

Given the following rewrite rule: RewriteRule ^user/([^/]*)$ /userprofile.php?user=$1 [L] How can I have it work either with or without a trailing slash? Bonus points, how can I verify ([^/]*) ...
5
votes
1answer
894 views

How to internally rewrite a page when requested from specific HTTP_HOST

I have a Drupal site, site.com, and our client has a campaign that they're promoting for which they've bought a new domain name, campaign.com. I'd like it so that a request for campaign.com internally ...
0
votes
2answers
161 views

Is it possible to mod_rewrite BASED on the existence of a file/directory and uniqueID?

My site currently forces all non www. pages to use www. Ultimately, I am able to handle all unique subdomains and parse correctly but I am trying to achieve the following: (ideally with ...
0
votes
1answer
688 views

.htaccess: Redirect Hotlink Flash --> Site with embed Flash

I have some PHP sites that embeds SWF files. These SWF files are now linked to by some other guys. And I don't want them to simply open the SWF, I want them to force being redirect to the page where ...
1
vote
3answers
2k views

Using env variables with RewriteRule and ErrorDocument

I'm having problems with the following while config. my Apache server to Rewrite some urls. SetEnv PATH_TO_DIR /directory RewriteRule ^%{PATH_TO_DIR}/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-\.]+)/?$ ...
1
vote
1answer
77 views

wrestling with some rewrites for Apache

I have upgraded my gallery2 to gallery3, and notice that some links no longer resolve correctly. Since the proper way is to redirect these with a 301, that is the way I'm going. The following series ...
1
vote
1answer
943 views

Mod_rewrite on Amazon S3

Is it possible to use mod_rewrite on Amazon S3? www.example.com/about.html -> mybucket.s3.amazon.com/index.html www.example.com/welcome.html -> mybucket.s3.amazon.com/index.html ...
1
vote
2answers
2k views

apache domain redirect to subfolder

I have a hosting account with godaddy. Its a linux system running apache. The way they do their setup is your primary domain is the root folder. When you add a subdomain its in a subfolder of the ...
1
vote
3answers
162 views

How to remove a file from url using mod_rewrite

I want http://www.foo.com/ to internally point to /var/www/home.php and http://www.foo.com/home.php to be redirected to http://www.foo.com/. Thus, I would like to fix the old ...
2
votes
2answers
3k views

Mod Rewrite - directing HTTP/HTTPS traffic to the appropriate virtual hosts

I have an Apache2 web server (v. 2.2.16) running on Debian hosting three virtual hosts. The first two hosts are HTTP only (server1 and server2). The last host is HTTPS only (server3). My virtual host ...
0
votes
1answer
553 views

Apache mod_rewrite for multiple domains to SSL

I'm running a web service that will allow people to create their own "instances" of my application, running under their own domain. These people will create an A record to forward a subdomain of their ...
3
votes
2answers
5k views

Rewrite for robots.txt and favicon.ico

I have setup some rules in which subdomains (my users) will default to where I have located the robots.txt, favicon.ico, and crossdomain.xml therefore if a user creates a site say ...
0
votes
2answers
85 views

RewriteRules targeting a directory result in a gratuitous redirect

I have a standard CMS-like RewriteRule set up in my .htaccess: RewriteRule ^(.+)$ index.php?slug=$1 Let's say I have a directory called "foo" in the root directory. For some reason, if you hit the ...
2
votes
2answers
114 views

Virtual hosting

I want to use domains like xxx.abc.domain.tld. The xxx is my folder to access. I tried it with the rewrite rules, but I can't get it working, because I don't know how to get the part xxx from the ...
2
votes
2answers
947 views

Need some help on tomcat URL mod_rewrite or mod_jk

I am trying to remove the context name from the URL of my server. Current URL - http://www.domainname.com/MyApp/ What I need to make is to make it available at - www.domainname.com/ So it is only ...
2
votes
2answers
679 views

Redirecting a CSS file based on .htaccess rules

I'm trying to hack the css files on OSTicket by replacing them with my own custom ones when a specific URL is accessed. The URL that is accessed for this example is ...
4
votes
2answers
5k views

htaccess execution order and priority

Can anyone explain to me in what order apache executes .htaccess files residing in different levels of the same path and how the rewrite rules therein are prioritized? For example, why doesn't the ...
1
vote
1answer
61 views

Simple mod_rewrite Question

I want to have everything that looks like this: /1/2/3/4/5/[...] to redirect to this: /index.php?u=/1/2/3/4/5/[...] unless the requested string is a specific file. So anything that doesn't have a ...
0
votes
1answer
394 views

Force www. on multi domain site and retain http or https

I am using CakePHP which already contains an .htaccess file that looks like: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) ...
8
votes
3answers
3k views

Forcing SSL and www in .htaccess

I'm looking for a way to force SSL and www. I've been able to force both separately but together I keep running into redirection issues. The following code works when handling a URL in this format: ...
3
votes
1answer
390 views

subdomains apache rewrite rules

Let's say I have my web folder as public_html. In there I have a sub folder. I can view the folder at: www.mydomain.com/sub & mydomain.com/sub What I want is: sub.mydomain.com This will show ...
3
votes
4answers
154 views

Question about mod_rewrite rule for redirecting failing pages

I'm setting up a mod_rewrite rule that redirects failing pages to a custom "Page Not Found" page. This is with WordPress. I've used an online tutorial from the Apache site and so far my rules look ...
4
votes
1answer
8k views

Properly force SSL with .htaccess, no double authentication

I'm trying to force SSL with .htaccess on a shared host. This means there I only have access to .htaccess and not the vhosts config. I know you can put a rule in the VirtualHost config file to force ...
1
vote
1answer
1k views

Using mod_rewrite to send all requests to a certain document

I want to temporarily redirect all requests for a site to index.html, using apache only. Is this mod_rewrite approach going to work, and is it the right way to do it? RewriteEngine on RewriteRule ...
2
votes
1answer
1k views

Joomla 1.6 URL rewrite on IIS7 (removing /index.php/)

Joomla 1.6 was released today and I'm wondering if anyone knows how to get rid of the /index.php/ part? How link looks now: http://www.example.org/index.php/stuff How link would look after URL ...
2
votes
3answers
281 views

How to use .htaccess to show smarter URLs

I'd like to ask how can I call the page www.domain.com/index.php?page=somepage and make the browser show the user in the URL bar the address www.domain.com/somepage/? How do I do that trick?
0
votes
1answer
794 views

Rewrite URL to a PHP script with parameters

I'm trying to create a service that you give it a URL like http://myhost.com/34.png and it will return the result of the script http://myhost.com/create_image.php?count=34. I know this is possible ...