.htaccess

How to prevent rewriting href attributes when rewriting urls?

Hello, on my web site i want to change url's from (just exemple): site.com/showCategory.php?catId=34 to: site.com/category/34/ Here is the contents of my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^affichage/([0-9]+)$ /affichage/$1/ [R] RewriteRule ^affichage/([0-9]+)/$ /affichage.php?n=$1 </...

How to encode URL in Apache mod_rewrite?

I'm now doing it this way: rewriterule ^questions/tagged/(.*) qas.php?q=[$1] Which didn't do encoding stuff yet. ...

redirecting to homepage rather than 404 error page!

Hi friends, I'm working with PHP. I have an .htaccess file like below, and it redirects to homepage rather than 404 error page :/ what can be the problem here? Appreciate helps! thanks a lot! ErrorDocument 404 /new/err404.html RewriteEngine On RewriteBase /new/ RewriteRule ^login.html$ index.php?s=login&a=loginDo [QSA,L] RewriteRule ...

Making a .htaccess rewrite rule respect subdirectories automatically

I'm making a downloadable self-hosted web app (using CodeIgniter), and need the .htaccess rewrite rule to be able to tell if it's in a subdirectory or not to be able to make the rewrite rule correctly. For example, if the app is being installed at example.com, then the write rule will look like RewriteRule ^(.*)$ /index.php/$1 [L] I...

creating a default varible in mod_rewrite

I have mod_rewrite take this url: mydomain.com/directory/index.php?slug=slug&year=2009 and make it pretty: mydomain.com/directory/slug/2009/ Easy, but now my issue is, if someone lands at the URL without the year attached (like: mydomain.com/directory/slug/), how can I add the current year to the URL? My current htaccess reads: R...

Add a header to each request using .htaccess

I want to add a custom header to a phpbb installation without touching the code. (Using .htaccess) The header is: Strict-Transport-Security: max-age=157680000 Any ideas? ...

start downloading file with ajax

Hello, I like to access my download.php with ajax, that way I can show a little downloadscreen in a div, BUT I have this in my htaccess file, that basicly says deny outside access for all pages. I forgot about it, while I was trying to access my download.php file with window.location = urlnieuw Is there a workaround for this problem...

Redirect specific file request (at any location) to specific location

I have a specific file, let's call it 'myfile.abc', that I need to have redirected to a specific location, no matter what location it's requested from. For instance: /folder1/myfile.abc /folder2/myfile.abc /folder3/myfile.abc I need all the above to be redirected to (as an example): /myfolder/myfile.abc How do I achieve that within...

Why won't svn let commit .htaccess files?

Try as I might, I can't commit .htaccess files from my windows svn client (tortoise svn). The error that is returned is: Could not read status line: Existing connection was forcibly closed by the remote host. And here is basically what my vhost looks like in Apache: <VirtualHost *:80> DocumentRoot /var/www/mydomain.com/legacy/...

How can I rewrite URLs?

I want to convert this URL: mysite.com/cgi-bin/test.cgi/some_random_numbers_and_letters/http/www.somewebsite.com into: mysite.com/www.somewebsite.com I also want to convert this URL: mysite.com/addname.php into: mysite.com/add/ How do I do that? ...

Reading the .htaccess DirectoryIndex and Rewrites with PHP

Is there an inbuilt way to read the active DirectoryIndex in .htaccess (or httpd.conf etc) with php? Also, is there a way to determine which file the httpd will execute using PHP given a url if rewrites are being used? Basically, given a URL, I want to use PHP to figure out which file the httpd would initially invoke. Thank you. ...

not able to 301 redirect url in drupal

i am trying to redirect an url from location a to b using .htaccess with the following code RewriteRule ^accessibility$ http://example.com/topic/accessibility/ [R=301,L] it is not working i have this turned on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301] ...

htaccess rewriteRule restrict access to one particular folder problem

Hello, I have problem with getting the folder inc restricted. It is only the inc folder in the root directory and not the inc folders higher up de hiarchie Problems are: IE will start a download/open dialog and FF displays an include file I don´t have this problem with the images folder wich is also in the root directory. What...

Complex htaccess rewrite rules - where do i start ?

Hi I have asked on here before about mod_rewrite and got the perfect answer but now I need to do something more complex and really needed the advice of someone who knows mod_rewrite much better. My rewrite rule looks like this so far: RewriteRule ([a-zA-Z_-]+)/([0-9]?) index.php?cat=$1&page=$2 And that shows the URL as follows: /cat...

Using mod_rewrite only if a 404 would have occured

I am in the process of converting a static website into one using a cms. I have the cms installed in a sub directory of the public directory. To avoid ending up with ugly domain names (http://example.com/cms/) is there an easy way using mod_rewrite to rewrite http://example.com/… to http://example.com/cms/… while ensuring that if the req...

mod_rewrite needed

lets says I have a domain example.com and I have wildcards dns switched on. on example.com a user can signup with username and password. once registration is done, username.example.com starts redirecting to example.com/script/script.php?user=username. address bar would still show username.example.com what would be the contents of the .h...

.htaccess 301 redirect problem

Hi I have an application which uses opencart. I would like to make a 301 reditect in case the user types http://mysite.com. To be redirected in http://www.mysite.com (301 status code) Here is my .htaccess content: #Options +FollowSymlinks RewriteEngine On #OPENCART REWRITES START RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...

Unable to make a 301 domain redirection

Hi I have an application which uses opencart. I would like to make a 301 reditect in case the user types http://example.com. To be redirected in http://www.example.com (301 status code) Here is my .htaccess content: RewriteEngine On \#OPENCART REWRITES START RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Re...

Pointing a subdomain to a subfolder using .htaccess

My webhost automatically forwards all requests to *.mydomain.com to the toplevel domain mydomain.com. I wanted to map any subdomain to a specific folder on my toplevel domain. i.e. sub.example.com must be mapped to example.com/someFolder (without change in the address bar). After digging around on the net, I came up with this: Rewrite...

Symfony: email address as request parameter

I'm having some issues with passing an email address in a url to a symfony app. The url looks like example.com/unsubscribe/email/[email protected] It will always result in a sfError404Exception, except when the period is removed. After doing some googling around, the only solution I've yet seen is that htaccess is bypassing the url beca...