I have a link that works by using a unique identifier product code. However I am trying to put the product name into the link but I am so far stuck with this.
Does anyone have any suggestions please?
This works..
/products/product/6550
This doesn't work..
/products/product/6550/clearance---hatherley-high-gloss-2-drawer-bedside-chest-in-walnut-and-red
htaccess file…
Options -Indexes
Options -MultiViews
Options +FollowSymLinks
# Prevent viewing of htaccess file
<Files ~ "^\\.ht">
order allow,deny
deny from all
satisfy all
</Files>
# Error Pages
ErrorDocument 404 /404-error.php
# Rewrite Rules
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]+)/([a-z\\-]+)$ /$1/$2.php [QSA,L]
RewriteRule ^products/product/([0-9]+)/(.*)$ products/product.php?product_id=$1 [QSA,L]
</IfModule>
Ironically, based on your htaccess file, it looks like the first should not work and the second should. Are you sure we’re seeing your full and latest htaccess?
I re-created your setup – PHP script at /products/product.php and copy-pasted your htaccess – but everything worked exactly like it was supposed to. So you’ve got something funky going on somewhere that we haven’t seen. My best guess is that you have another htaccess file with different code somewhere in that directory path.
wilderness-wally.com does just what you’re asking for and the information you’re seeking is in the tutorial linked in my signature - just ignore the comment which will follow this post.
dklynn is referring to me, and the comment he wants you to ignore is that his tutorial in several places contradicts the official Apache documentation and contradicts observable behavior in Apache, and that you’d be much better off learning from the official Apache documentation.
I’m sorry to have to give you the same kind of answer, but the change you posted to make it work with letters instead of numbers is correct, so if it isn’t working, then there’s some other contributing factor that we haven’t seen here.
What I have is a blog. When I use the unique number of the blog post code works fine. But when I try to filter it by the category for example “General” and use [a-z] I cant get the code to work.
But when I replace “General” with a number such as “1” and used [1-9] I can get the code to work.
Is there anyway this can be tidied up as it creates a major problem. I want to put the name of the product after the unique product ID but it now affects all the links which have a query in.
Is it possible to isolate only the product line as one which has a second variable after the one I am querying?
Does anyone have any suggestions on what I can do to fix this? Unfortunately I have messed up my whole site by trying to add the slug into ine set of links.