spires Posted May 31, 2008 Share Posted May 31, 2008 Hi Guys. I'm trying create a dynamic website, but also making it SEO Friendly. I am currently reading 'Professional Search Engine Optimization with PHP', which seems to be a great book on the subject. However, I have hit a wall. So, If you know anything about URL rewriting, then please can you help. So far I have (MAC): - Contacted my hosting, and they have said: "The Apache mod_rewrite module is already loaded by default on the apache installation that comes with Redhat 4ES." - Removed # from: #LoadModule rewrite_module libexec/httpd/mod_rewrite.so - Removed # from: #AddModule mod_rewrite.c - Restarted Apache - Created .htaccess file with the following information: RewriteEngine on # Translate my-super.product.html to /product.php?product_id=123 RewriteRule ^my-super-product\.html$ /product.php?product_id=123 But, I just get the error: the webpage does not exist. Please can you help, as I can't see what else I can do. Thanks in advance Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 31, 2008 Share Posted May 31, 2008 remove the backslash in your rewrite url and i'd remove case-sensitivity and leave after this rule: RewriteRule ^my-super-product.html$ /product.php?product_id=123 [NC,L] Quote Link to comment Share on other sites More sharing options...
spires Posted May 31, 2008 Author Share Posted May 31, 2008 Hi, Thanks for your help. I've changed the .htaccess to: RewriteEngine on # Translate my-super.product.html to /product.php?product_id=123 RewriteRule ^my-super-product.html$ /product.php?product_id=123 [NC,L] But it is throws me out. Am I doing it right? Thanks once again. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 31, 2008 Share Posted May 31, 2008 what do you mean 'it is throws me out'? can you just have /product.php echo something for now to make sure the forward is working? Quote Link to comment Share on other sites More sharing options...
spires Posted May 31, 2008 Author Share Posted May 31, 2008 Yes, product.php is echoing: You have selected product # (variable) at the moment I'm get an error: HTTP Error 404 - File or directory not found. So the redirect is not working. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 Whats up with the character where the space should be after "RewriteRule"? Edit: Pretty difficult to display the char, it's very similar to this: ┤ Quote Link to comment Share on other sites More sharing options...
spires Posted May 31, 2008 Author Share Posted May 31, 2008 I don't know. I took this code directly out of the book I'm reading from. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 Oh. If you did the same in the actual htaccess file (copy-pasted it), try retyping it and save. Quote Link to comment Share on other sites More sharing options...
spires Posted May 31, 2008 Author Share Posted May 31, 2008 Yeah, It was typed in the first place. So, do you reckon that it is the .htaccess file that is the problem then? If so, at least I know what to work on. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 If nothing works, play around with setting the RewriteBase. Maybe it's set wrong somehow. Quote Link to comment Share on other sites More sharing options...
spires Posted May 31, 2008 Author Share Posted May 31, 2008 OK, Thanks for all your help. I play with it a bit more. Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 Wait a second, your comment says "my-super.product.html", but the actual rewrite rule says "my-super-product.html" (note the second hyphen). Topic solved? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted May 31, 2008 Share Posted May 31, 2008 Just tested this: RewriteEngine on RewriteRule ^my-super-product.html$ product.php?product_id=123 It works when placed in the same folder as product.php. Note that I removed the slash in front of the "product.php?product_id=123" part. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.