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 Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/ 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] Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554278 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554291 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? Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554301 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554307 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: ┤ Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554308 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554311 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554312 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554314 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554317 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554319 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? Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554324 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. Link to comment https://forums.phpfreaks.com/topic/108134-url-rewriting-please-help/#findComment-554332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.