.htaccess

.htaccess Optional characters?

Though .htaccess, I want to redirect /page/var1/var2 to ./page.php?var1=var1&var2=var2. This is very easy BUT I want to make it so /page/var1 also redirects to ./page.php?var1=var1 (without having the var2). The only way I'm doing this is: RewriteRule page/(.*)$ ./page.php?var1=$1 RewriteRule page/(.*)/(.*)$ ./page.php?var1=$1&var2=$2 ...

www to non-www redirection .htaccess code not woking on my site?

I want to redirect http://www.example.com to http://example.com via .htaccess. I've found and tried below listed codes but nothing works. can any body tell me the solution. I get this error Socket Error 10049 on all codes when i type http://www.example.com My hosting's Apache version is 2.0.63. My .htaccess file is in a public_html/ O...

Rewrite URL from http://example.com/blog/ to http://blog.example.com/

What RewriteRule (using .htaccess/mod_rewrite) should I use to redirect http://example.com/blog/ (with www or without) to http://blog.example.com/ ? I'm using the following, but getting a redirect loop: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule ^(.*)$ http://www.example.com/blog/ [L,R=301] Rewrite...

'Masking' external url links using RewriteProxy derictive

Hi I have a simple rewrite rule that writes to an external domain using the Helicon Isapi_Rewrite 3 RewriteProxy derictive. Example: RewriteProxy blog http://blog.com However, links on the external site are not masked by the proxy as I would have expected them to be. They are still pointing to http://blog.com/link1 rather than http://...

Custom error pages using only one file...

Although I'm sure it's possible I cannot see how I would be able to do the following. Using .htaccess to point the html errors to a single error handling page (this bit not a a problem). That page then checks what the error code actually was (404, 500 etc.) and displays a message according to each one. I am trying to do it in a PHP en...

How do I modify sys.path from .htaccess to allow mod_python to see Django?

The host I'm considering for hosting a Django site has mod_python installed, but does not have Django. Django's INSTALL file indicates that I can simply copy the django directory to Python's site-packages directory to install Django, so I suspect that it might be possible to configure Python / mod_python to look for it elsewhere (namely ...

Redirect files to simple form before downloading

Hi I am trying to redirect all links to any pdf file in my site to a page with a form in it that collects user info before they can proceed to download/view the pdf. Eg I want to redirect *.pdf files in web site to request.php?file=name_of_pdf_being_redirected Where request.php is the page with the form on it asking for a few details ...

.htaccess redirect main domain?

How can I redirect requests to mydomain.tld/somepage.ext to mydomain.tld/mydomain/somepage.ext? I have subdomains like subdomain.mydomain.tld that I don't want to be affected by this. I can't seem to get it to work right. I'm trying this: RewriteEngine on RewriteCond %{HTTP_HOST} mysite.com RewriteCond %{REQUEST_URI} !^/mysite Rewrit...

ISAPI Rewrite with instead of mod_rewrite

I'm installing Modx on windows with ISAPI Rewrite instead of apache with mod_rewrite? How do you define the rewrite rules? I'm guessing not with an .htccess file? any Ideas? Thanks ...

The correct way to make a rewrite rule?

I have a .htaccess in my site www folder that has this rewrite rule: RewriteRule ^(\w+)/?$ /$1.php It works, if you type in http://sampardee.com/urltest - It finds urltest.php and brings it up. However, if you type in http://sampardee.com/urltest/ it still brings urltest.php up but the CSS stops working. I have the CSS file specified ...

Making a rewriterule remove .php extension?

Hello, I have come up with a rewriterule to to go to any page on my website without typing in the .php extension because it is automatically added to the url. The rule is: RewriteRule ^(\w+)/?$ /$1.php It takes anything you type in my index and adds .php to it, so you can put in http://sampardee.com/index and it pulls up index.php Now...

.htaccess rewrite without www AND redirect to subdirectory

I'd like to redirect www.example.com/* to example.com/* And at the same time redirect example.com/* to example.com/forum/* But I also have /wiki/ and /blog/ and /style/, so I don't want to redirect example.com/style/* to example.com/forum/style/* This is what I have at the moment, which is not working quite correctly: Opti...

Mod Rewrite and PHP

I am trying to redirect pages using mod_rewrite to the pages with some variables (for using them with PHP's $_GET). To give an example with few lines: When the user enters /c/stg it redirects to item_show.php?id=$1&f=1 (where f is page number). When the user enters /c/stg/2 it redirects to the second page with show.php?id=$1&f=$2. I...

htaccess Authentication with PHP

On the current website I'm working on, I've got a directory of files for users to download which would be really nice to have some security method other than obscurity ;) I was wondering if there's any way to supply login information via PHP to htaccess as though a user were entering it. Alternately, if anyone knows a better way to sec...

Need help on Apache htaccess redirect rule

I need to redirect from path /articles/20090425-swine-flu-kills.html to /2009/04/swine-flu-kills.html In the original path, the digits after articles are the dates in yyyymmdd format. This to convert to "/yyyy/mm/" in the new path. I suppose need some regex but I am not sure how. Would appreciate help. Thanks ...

500 Internal error when using mod_rewrite in .htaccess

I have no idea why, but every time I do something with a complex pattern for a RewriteRule in a .htaccess file, I get a 500 internal error. My current .htaccess file in its entirety is: RewriteEngine on RewriteRule ^ups/sections/([A-Za-z]{3})/([A-Za-z0-9_-+\.]+)/?$ /dl.php?loct=sec&sec=$1&file=$2 [R=302] I've tried with only "RewriteE...

Apache rewrite rule forces download

...

.htaccess redirect after replace a word?

Hello, I need to use .htaccess file to replace a world in URL something like this: example URL: http://example.com/oldword/test-page.html redirect to: http://example.com/newword/test-page.html how can I use mod_rewrite to redirect every URL containt "/oldword/" to the same URL after replacing that word? ...

Removing .htaccess Authentication Restrictions

I have a project that has .htaccess Authentication but i want to remove it for a certain assets folder. i tried adding a htaccess in that folder with : AuthType none Satisfy Any Allow from All Order Allow, Deny but it doesnt seem to work :( Any thought on this. Thank you so much Edit The directory i am trying to unprotect is not a ...

Redirect .com to .org in .htaccess

I have domain.com and domain.org as aliases pointing to the same vhost. How can I use .htaccess to redirect all domain.com requests to domain.org? ...