mod-rewrite

htaccess redirect problems

My .htaccess looks like this: RewriteEngine on RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)|(\.swf)|(\.xpi)|(\.ico)|(\.src)$ RewriteCond %{REQUEST_URI} ^(.*)$ #RewriteCond %{REQUEST_FILENAME} ! -f RewriteRule (.*)$ view.php?picid=$1 [L] Problem is that when I visit www.example.com, it’s sending me to v...

apache mod_rewrite affecting files inside sub folder

Options +FollowSymlinks RewriteEngine On RewriteBase /mysite RewriteRule ^([^/\.]+)/([^/\.]+)/?$ page.php?p=$1&name=$2 [NC,L] RewriteRule ^([^/\.]+)/?$ page.php?name=$1 [NC,L] The above code is written in my .htaccess file. I want my URL from: http://localhost/mysite/page.php?p=categoryname&name=article_title http://localhost/my...

Rewrite Query String

I have this URL: oldsite.com/profile.php?uid=10 I would like to rewrite it to: newsite.com/utenti/10 How can I do that? UPDATE: I wrote this: RewriteCond %{QUERY_STRING} ^uid=([0-9]+)$ RewriteRule ^profile\.php$ http://www.newsite.com/utenti/$1 [R=301,L] But $1 match the full query string and not just the user id. ...

Allow/deny image hotlinking with .htaccess

So I've got this in my site .htaccess file to prevent hotlinking of images, JS and CSS from all other domains. RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC] RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L] Question: How would I selectively allow one or two domains to hotlink? ...

Apache mod rewrite returns blank screen for php files with wordpress header included

Here's simplified .htaccess file: RewriteEngine On RewriteRule ^index$ index.php On my local lamp server everything works fine, but there are some problems on production server. myurl/index returns only blank screen, php is not parsed. When required file is accessed directly (myurl/index.php) it works fine. I noticed that this prob...

Why doesn't apache show a 404 error when I send a 404 header with php?

Hello, I have a header('HTTP/1.0 404 Not Found'); somewhere along the code but it doesn't redirect to the Apache's default 404 page for some reason. I have a Rewrite Rule on the .htaccess file that redirects every request to index.php. Could that be the problem? Thanks in advance, Omer. ...

mod rewrite beginner questions

How would I rewrite script.php?id=3295 to script/3295?? and Im also wondering if someone could explain what these 3 RewriteConds does: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l Thank you very much ...

mod_rewrite acting like redirect to another domain? How do I make a rewrite?

Hello! I want to redirect www.mydomain.com/store to http://store.anotherdomain.com/me When I use RewriteRule ^store$ http://store.anotherdomain.com/me it ends up redirecting, meaning the URL changes, rather than remaining www.mydomain.com/store What do I need it to do to do the rewrite properly? When I use RewriteRule ^next$ /mydomai...

Javascript rating bar don't work with modrewrite urls

In my script, this function parts build links: if ($type == "mod_rewrite") { $prepend = ""; $append = ".html"; } else if ($type == "query_string") { $prepend = 'index.php?params='; $append = "/"; } // // // $gamelink = 'game/id/gamename' (example) /* 'game' is a fixed string. 'id' and 'gamename' are...

mod_rewrite messing up includes

Hi. I have the following mod_rewrite rule: RewriteRule ^home/ home.php [L] Fairly simple. When I head to home.php, everything loads fine, but when I head to me.com/home/, the CSS doesn't load. CSS draws from lib/css/home.css which isn't in the same folder.. To clarify, my structure is: /htdocs home.php /lib /css home....

can get this .htaccess file to work for friendly url !

Options +FollowSymLinks -MultiViews -Indexes RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME}\.php -f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/$ $1.php RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{...

.htaccess redirecting errors

First off I am using the Codeigniter Framework so this issue is a workaround the way CI process URLs along with the current redirects I have set up using mod_rewrite. I am trying to get a URL like this /?gclid=somestringgoeshere to redirect to /index.php?/home/gclid/somestringgoeshere. The current .htaccess I have set is below <IfModu...

how to write a rewriteCond in .htaccess to exclude a subdir and its subdirs

Hi, I have the following problem. I have a website and a blog in a subdirectory. Both of them are php. I have a .htaccess file in the root folder and another one in the blog folder. I dont' think is relevant, but the blog script is wordpress. I added a condition in the root .htaccess to skip the requests made for the blog, rewriteCon...

Rewrite only a specific file using MOD_REWRITE

I have a file that can be reached using multiple paths: http://mydomain.com/portal1/movie.swf http://mydomain.com/portal2/movie.swf http://mydomain.com/portal1/substep/movie.swf etc. I want a rewrite rule to get this specific file from the following path: http://mydomain.com/movie.swf How can I do that? ...

Permissions set to 777 and file still not writeable

I have set file permissions to 777 yet I cannot write to the file with PHP. I can clearly see in my FTP client that the file has 0777 permissions and when I do: echo (true === is_writable('file.txt')) ? 'yes' : 'no'; I get 'no'; I also tried: echo (true === chmod('file.txt', 0777)) ? 'yes' : 'no'; With the same result. The direc...

mod_rewrite help

For some unknown reason, my rewrite rule does not fire. Can you advise ? /extranet/.htaccess (1) /extranet/stable/ /extranet/dev/ /extranet/dev/.htaccess (2) The first .htaccess redirects all traffic to the stable folder, except for URLs specifically pointed at the dev folder. That works fine. Inside the dev folder, the second .htac...

Rewriting an url for a user-defined domain

I'm not entirely sure if this is possible and tried searching but couldn't find the exact answer to my current situation. I'm building a service which should allow users to point their own domain to the service. (they need to point an A record towards my server ip) I'm able to catch the domain using the catch all in apache. So I made ...

Wordpress "search engine friendly" urls ( permalinks) implementation

I had the pleasure to take a peak at Wordpress source code; i was wondering how they managed the custom url feature, but i couldn't really get it. The rewrite rules inside wordpress .htaccess file simply redirect all requests to index.php. After that, it's a mystery to me: how do they make example.com/this/title/is/cool/ match index.ph...

mod_rewrite fail: .htaccess or server config issue?

The application i'm developing uses a certain file directory structure. Via the use of mod_rewrite and .htaccess files, i manage to have friendly urls for our users. It works fine on my local server, but once on the production server, it fails: apparently, the server throws a 404 error before the .htaccess has a chance to kick in. Here ...

How do .htaccess redirects work?

I am trying to understand how .htaccess redirects work. Say for instance, my user navigates to: www.website.com/users/bob How can I redirect that user to: www.website.com/users.php?user=bob ...