mod-rewrite

show php file like a directory with htaccess

hi i want something like this when user write www.test.com/6 in the behind it will go to http://www.test.com/index.php?id=6 but this is not redirection it will be mod_rewrite i do something like this but i get internal server error Options +FollowSymLinks RewriteEngine on RewriteRule ([0-9]*)$ /index.php?id=$1 [L,NC] ...

Fixing mod_rewrite and mod_alias conflict

I have a VirtualHost setup like this : Alias /somedir /some/other/dir http://example.com/somedir works fine However, I need to setup mod_rewrite for /somedir (a CodeIgniter app for which I want clean URLs). Here's the bit from the CodeIgniter wiki : RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQ...

Problem with duplicate urls after rewrite

Hello, Can you help me solve this problem, please. In my .htaccess file I used this rewrite rule: rewriteRule ^country/([0-9]+)/([0-9]+)/([0-9]+)/(.*)/(.*)?$ search.php?loc1=$1&loc2=$2&loc3=$3 [L] To get this kind of urls: /country/13/196/2693/germany/frankfurt Everything works fine, but I get unwanted duplicate URLs also: /...

Allowing foreign characters in .htaccess mod_rewrite

Is there a way to allow foreign characters in .htaccess mod_rewrite character sets? i.e., a way to add foreign characters like ç and others to ([A-z]+) ? ...

Provide an alternative URL for an existing one

Hello, I need some help. I have a page at /register. However, I also want to be able to view this register page at /book-your-place-now. I know that is possible with .htaccess but I cannot for the live of me get me head around .htaccess files. ...

ubuntu returns 500 error when .htaccess enabled

I'm currently moving a dev magento build to my live test subdomain on ubuntu and using Easy Hosting Control Panel (EHCP). If I rename my .htaccess file to .htaccess and refresh my subdomain url, I get an internal server error 500. If I rename the .htaccess file to .htaccess.bak, and refresh, the subdomain displays my magento store fine....

WordPress and ReWriteRule

I have a product-details template in my theme that handles display for different products based on the URL. By default, WordPress will allow a number to be passed to the template page by appending to the URL: product-details/3/ However, I want to make this to be more SEO Friendly using a slug: product/sandals. Yet, when I do so, WordPr...

mod_rewrite docroot to multiple subfolders dependant on subfolder name

I've been trying to get some RewriteRules working and am successful when just using for one host, but not multiple. I'm wanting "http://preview.domain.com" to point to "http://preview.domain.com/dir1" or "http://preview.domain.com/dir2", etc. Dir1 and Dir2 are as they contain a ProxyPass that points to the real domain. Here is what I...

htaccess a dynamic URL

I'm using Wordpress with a plugin and it's currently making urls like this: http://www.example.com/?name=the-office I would like to redirect all similar urls to http://www.example.com/name/the-office Current htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCo...

Problems with rewrite module and negation patterns

I have the following problem: If the url contains the keyword "formulario-" and it is a http connection, I want to redirect to the https version. If the url doesn't contain the keyword "formulario-" and it is a https connection, I want to redirecto to http version. I tried the following .htaccess but it doens't work properly: Rewrit...

Rewrite rules help

Could I have some help with rewriting: http://localhost/forum/thread.php?id=300491 http://localhost/forum/?id=3 http://localhost/forum/thread.php?id=300491&amp;page=103 http://localhost/forum/post.php?tid=300491 http://localhost/forum/post.php?fid=3 To: http://localhost/forum/thread/300491 http://localhost/forum/3 http://localhost/fo...

Subdomain Rewrite Logic

Hello, I have the following Rewrite Logic, and it's working to redirect the subdomain, partially. If I visit the URL http://subdomain.clientcollabhq.com/some/path it redirects properly, but if I visit http://subdomain.clientcollabhq.com/ it skips the RewriteCond blocks for the subdomain and falls into the fallback RewriteRule. Any idea ...

Regex match this OR that?

What is the regex for this? Match if string NOT ( ends in .php OR ends in .html OR contains / ) Thank you! Edit: I need the NOT part because the expression is to be used on an Apache mod rewrite, since I can't change the logic of mod _rewrite to avoid the NOT. Edit: My initial effort was ([^/]+)(.html)$(^.php)$ -- which is...

Rewrite rule does not pass $1 when using ! ?

I am using this rule: RewriteRule !^(.*?/.*|.*?\.(?:php|html)$)$ headers.php?a=$1 [L] (based on the great contributions on http://stackoverflow.com/questions/3345747/regex-match-this-or-that) It rewrites to headers.php when I type localhost/foo but the a variable is empty instead of foo (I checked with var_dump($_REQUEST)) Any idea ...

mod_rewrite for friendly urls unexpected behaviour

I have Apache and I have this in the .htaccess file: RewriteEngine on RewriteRule ^myhome myhome.php because I want to redirect /myhome/ to /myhome.php. It works, but it behaves unusually. When I type in myurl.com/myhome, it redirects to myurl.com/myhome.php correctly, but when I try myurl.com/myhome/ with the slash at the end, it red...

php and non existing files

on my site i call non existing files and it show index page not error 'not found page'. but i need to get this error, any ideas? update here my htaccess file # BEGIN WPSuperCache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / AddDefaultCharset UTF-8 RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} !.*=.* Rewrite...

Using mod_rewrite to redirect unsupported language codes

Hi there- I'm developing a multilingual site, and I'm using language identifiers in urls in conjunction with a front controller such that visiting http://www.domain.tld/en/content or http://www.domain.tld/de/conent will pull up content localised in those languages. If the site is visited without specifying a language identifier, th...

PHP Redirection (301) hiding query string

Hi there, I'm trying to redirect a page using PHP (I think it has to be PHP as opposed to .htaccess as there are a lot of pages involved and the information required to do the redirect is held in a datbase). The page i'm trying to to a redirect from is already re-written, and looks like: www.example.com/shop/deptartment/section/produc...

.htaccess fix for a pretty permalink in PHP?

Maybe I'm going about this in the wrong way, but I have some pages in our homegrown CMS that I want to convert to using pretty permalinks. Currently, their page URLs look this this: http://ourdomain.com/articles/?permalink=blah-blah-blah I want to convert these to: http://ourdomain.com/articles/blah-blah-blah I have a column in the d...

How to rewrite /foo to index.php?x=foo but also /foo/bar to index.php?x=foo&bar=true in one RewriteRule?

Using Apache's RewriteEngine, how to rewrite /foo to index.php?x=foo but rewrite /foo/bar to index.php?x=foo&bar=true in one RewriteRule? I have this now: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)? index.php?x=$1 [L,NC] # rewrites /foo to index.php?x=foo, but not /foo/bar to index.php?x=f...