Owen Ffrancon
Owen Ffrancon

Reputation: 73

Mod_rewrite does not work when following hyperlink

I'm building a portfolio (link here) that works like this:

The problem is that these hyperlinks bring me to the non re-written page (/idea.php?url=example-idea) even though /idea/example-idea works fine.

Example: Clicking on the Pedal-Powered Music Machine item brings me to /idea.php?url=music-machine-r48 even though the hyperlink is to /idea/music-machine-r48, which is causing problems with JQuery which is reading from the address bar.

This is my .htaccess file:

RewriteEngine on

RewriteRule ^idea/([A-Za-z0-9-]+)/?$ idea.php?url=$1 [NC,L,NE] 

RewriteCond %{HTTP_HOST} !^owenpickering.com$ [NC]  
RewriteRule .? http://owenpickering.com%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule .? /404.php [L]

Any ideas? Thanks in advance.

Upvotes: 1

Views: 21

Answers (1)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try this,

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^idea/([A-Za-z0-9-]+)/?$ idea.php?url=$1 [NC,L,NE] 

#this is causing the redirecting
#RewriteCond %{HTTP_HOST} !^owenpickering.com$ [NC]  
#RewriteRule .? http://owenpickering.com%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule .? /404.php [L]

Upvotes: 1

Related Questions