mod-rewrite

mod_rewrite rules for all web documents

I am in need of the rewrite rules and conditions to evoke a central PHP script for every and any web document requested on my server. Just to add, I do not want the PHP script to be evoked when requests are made for CSS, JS, PNG, GIF, JPG, and other media etc. I only want the script to be called for HTM, HTML and PHP documents in the roo...

Why is my LAST rule [L] not working in apache?

Background, I'm running a Zend Framework application. Trying to squeeze the most performance out of it as possible. So I'm trying to move the rules out of .htaccess exactly to the letter per this blog post by the author of a Zend Framework book: http://www.armando.ws/2009/03/how-to-run-zend-framework-with-no-htaccess-file/ So basically,...

mod_rewrite rule and setenv

Is there anyway to use the value set in a SetEnv on the RewriteRule statement? Example: SetEnv MY_SCRIPT myScript.php rewriteEngine on RewriteRule ^(.*)$ %{MY_SCRIPT} [L] ...

Safe to have page resources without file extensions?

I need to decide on naming conventions for a new website. I can use mod_rewrite at will. My favourite solution would be to work with no file extension at all. www.exampledomain.com/language/pagename this would lead to "pagename" being treated as a directory. I would have to take that into account when using relative links. Are there...

Rewrite rule not working

I want to write a rule that redirects all URLs of a certain pattern to a PHP file. Exception: the control/ directory where the CMS resides. Why does RewriteCond %{REQUEST_URI} ^/([^control]+)/([^/]+)$ RewriteRule .* /pages/index.php?language=%1&page=%2&%{QUERY_STRING} [L] not work for domain.com/deutsch/start (it throws a 404...

How to remove a cookie in Apache

I need to remove a cookie from the HTTP request that gets to the server. Doing it on the client (that writes this cookie) or on the server (that reads it) is not an option. I have Apache 2.0 that proxies requests between client and the server, so I was hoping to remove the cookie right there in Apache using mod_rewrite. My question is,...

Using mod_rewrite to work with a custom string

I want to rewrite everything that uses this pattern... /test/?TEXT=TRUE and allow it to be /test/TEXT AND /test/TEXT2, and so on. ...

htaccess rewriterule parent folder only

I would like to change the rewrite rule to only apply to the current folder that the htaccess file is in RewriteEngine on RewriteRule ^(.*)\.html $1\.php how do I change this to make that work? Thanks, ...

Apache rewriteRule for root directory

I used to have the following rule in my .htaccess while building a website: RewriteRule ^test/(.*) cgi-bin/router.py?request=$1 [NC] Whenever the user goes to mysite.com/test/something they get redirected to cgi-bin/router.py?request=something. This worked very well. I have now finished the site and want to 'turn it on'. However simpl...

mod_rewrite proxy RewriteRule not working

I need to send all requests for the directory home/alphauser to backend/alphauser, but not requests to files inside the home/alphauser directory. For example: http://home/alphauser -> http://backend/alphauser http://home/alphauser/ -> http://backend/alphauser http://home/alphauser/icon.png -> http://home/al...

What's the best way to strip out script tags from a URL string?

I'm getting a vulnerability alert from Mcafee Secure saying that there is an XSS vulnerability on my site. The string they use to produce it is: https://www.mywebsite.com/%3E%22%3E%3Cscript%3Ealert%28123%29%3C/script%3E%3C%22/www.mywebsite.com/my-product.html?ref=443%2Fanother%5Fpage%5Fon%5Fmy%5Fsite.php I can't get the alert to disp...

Mod Rewrite complete befuzzlement

Here is my .htaccess file Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteRule subpage\?sid /index.php [R=301,L,NC] My request is http://example.com/subpage?sid It keeps returning 404 Not Found, rather than redirecting to index.php I have tried not escaping the ? and changing the request to http://example.com/subpage\...

mod_rewrite works in .htaccess files but not in apache2.conf

I have the following in a .htaccess file as a test: RewriteEngine on RewriteRule ^(.*)$ /backend/$1 This works as expected. I was able to get rewrite logging working with the following in apache2.conf: <IfModule mod_proxy.c> RewriteLog "/tmp/REWRITE.log" RewriteLogLevel 9 </IfModule> The log file is created and logs debug inf...

Using 'mod_rewrite' how do I force HTTPS for certain paths and HTTP for all others?

I have a PHP-Apache application using mod_rewrite for clean URLs. I am having a lot of touble getting certain pages and paths forced to HTTPS while also ensuring all others will remain as HTTP. Here is an example of what I mean: // http://www.example.com/panel/ -> Should always redirect to HTTPS // http://www.example.com/store/ -> Sho...

Why won't this Apache modrewrite RewriteRule work?

I'm trying to get Apache mod rewrite to work on my local machine. I'm running OSX with PHP 5 and the Apache mod rewrite module is enabled. I have a directory called localhost/~Jason/hfh/admin with various PHP includes called based on a $_GET variable. I want to let users type (in theory) localhost/~Jason/hfh/admin/pages and have tha...

htaccess (https to http)

Hi, this is yet another .htaccess question. And I already did my literature review. Would appreciate any help. Requirements: Force HTTPS only for a few URLs. Browser shouldn't say partially encrypted page for SSL pages. I am using CodeIgnitor and tweaked the *base_url* in config.php to: $config['base_url'] = (isset($_SERVER['HTTPS...

Redirecting a /?p=xxx wordpress URL

I need to redirect a single Wordpress URL that is formatted like this: www.bluewidgets.com/?p=123 to a clean URL on another domain. How can I do this via .htaccess? All of the tutorials I've seen say that I need to specify another part of the url, like index.php, before the query string, but my URL doesn't have one - it's just the domain...

mod_rewrite "too many redirects" problem

Trying, <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^TRACE RewriteRule .* - [F] RewriteCond %{HTTP_HOST} ^(.*)dev\.example\.edu$ [NC] RewriteRule ^/test(.*)$ http://dev.example.edu/test/index.php/test$1 [NC] </IfModule> on an apache 2.2 server, to get this rewrite working to hide the "index.ph...

Why won't this mod-rewrite rule work?

I have a development site on my machine at localhost/~Jason/hfh/admin/?admin=collections My .htaccess file is in the /hfh/admin/ directory. It says: RewriteEngine On RewriteBase /~Jason/hfh/ RewriteRule ^([A-Za-z0-9\-\_]*)$ index.php?admin=$1 But when I go to localhost/~Jason/hfh/admin/collections I get a "page not found" error...

Apache mod-rewrite redirect domain name using querystring

We have a client who has many branches around the UK. Some of their branches have their own sites with their own domain names. The client has a part built system where visiting: www.client.com/aboutus.php?id=branchId shows the About Us page for that particular branch. What I need is a way to map specific domains to their branchId (thi...