fry2010 Posted May 24, 2011 Share Posted May 24, 2011 Ok, I will try to explain this as easy as I can. I want to navigate to 'www.bargainadds.co.uk/local-adverts/general'. Yet I want this to instead redirect to 'www.bargainadds.co.uk/adverts' and give the 'general' part as a GET variable. So basically I am looking to change it to 'www.bargainadds.co.uk/adverts.php?$i=general' The 'general' part may change, because it is a variable. It is just displayed as folders even though I want it to convert to the /adverts.php?i=... part. The problem is I already have some code that redirects pages without the file to the index.php file in the folder if one exists, here is the .htaccess file: Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] RewriteCond %{HTTP_HOST} ^bargainadds.co.uk RewriteCond %{HTTP_HOST} !^bargainadds.co.uk/local-adverts/(.*)$ RewriteRule (.*) http://www.bargainadds.co.uk/$1 [R=301] As you can see I have attempted to stop this from working on the 'bargainadds.co.uk/local-adverts/(.*)$' part but it does nothing. It still gets directed to the index, when it should be saying page not found. Link to comment https://forums.phpfreaks.com/topic/237377-help-re-write-issue/ Share on other sites More sharing options...
fry2010 Posted May 24, 2011 Author Share Posted May 24, 2011 I have had this working on my local computer: RewriteCond %{REQUEST_URI} ^/www.bargainadds.co.uk/local-adverts/(.*)$ RewriteCond %{REQUEST_URI} !^/www.bargainadds.co.uk/local-adverts/images/(.*)$ RewriteCond %{REQUEST_URI} !^/www.bargainadds.co.uk/local-adverts/discount-slip(.*)$ RewriteCond %{REQUEST_URI} !^/www.bargainadds.co.uk/local-adverts/search(.*)$ RewriteRule ^(.*)$ /www.bargainadds.co.uk/adverts.php?q=$1 [L,QSA] But it does not work on live. I have also tried changing the %{REQUEST_URI} part etc.. Link to comment https://forums.phpfreaks.com/topic/237377-help-re-write-issue/#findComment-1219797 Share on other sites More sharing options...
fry2010 Posted May 25, 2011 Author Share Posted May 25, 2011 sorry, managed to sort the problem out. I had to make the Conditions appear before the other conditions and also remove the 'www.bargainadds.co.uk' part before directories. Link to comment https://forums.phpfreaks.com/topic/237377-help-re-write-issue/#findComment-1219812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.