Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Damaged htaccess File With Slug In Link

General discussions related to php

Moderators: macek, egami, gesf

Damaged htaccess File With Slug In Link

Postby justlukeyou » Tue Jul 16, 2013 10:09 am

Hi,

I have caused a major problem with my site. I have tried to add a slug to the link.

So instead of..

.com/product/12345

I know have...

.com/product/12345/large-red-widget.

However the changes I have made to my htaccess file have now affected all the other links on my site which run from a query. Can anyone advise how to amend the htacess file just so it impacts on products


Code: Select all
ptions -Indexes
Options -MultiViews
Options +FollowSymLinks

# Prevent viewing of htaccess file
<Files ~ "^\.ht">
order allow,deny
deny from all
satisfy all
</Files>

# Disable directory listing from this point
Options -Indexes

# Error Pages
ErrorDocument 404 /404-error.php

# Rewrite Rules
<IfModule mod_rewrite.c>
RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^products/product/([0-9]+)/(.*)$ products/product.php?product_id=$1 [QSA,L]
  RewriteRule ^articles/article/([0-9]+)/(.*)$ articles/article.php?ID=$1 [QSA,L]
    RewriteRule ^articles/articlesfiltered/([A-Za-z]+)/(.*)$ articles/articlesfiltered.php?articlecategory=$1 [QSA,L]
  RewriteRule ^plusstyle/plusstyle/([0-9]+)/(.*)$ plusstyle/plusstyle.php?ID=$1 [QSA,L]
   RewriteRule ^plusstyle/plusstylesfiltered/([A-Za-z]+)/(.*)$ plusstyle/plusstylesfiltered.php?articlecategory=$1 [QSA,L]
     RewriteRule ^([a-z]+)/([a-z\-]+)$ /$1/$2.php [QSA,L]
</IfModule>
justlukeyou
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Feb 02, 2011 4:23 am

Re: Damaged htaccess File With Slug In Link

Postby johnj » Wed Jul 17, 2013 8:32 pm

I have not tested this but what you want should be something like this
Code: Select all
RewriteCond %{THE_REQUEST} ^GET\ /12345/
RewriteRule ^12345/(.*) /12345/large-red-widget/$1 [L,R=301]
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Damaged htaccess File With Slug In Link

Postby johnj » Wed Jul 17, 2013 8:33 pm

if that does not work you can also try this
Code: Select all
RewriteRule ^12345/(.*) 12345/large-red-widget/$1
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP General

Who is online

Users browsing this forum: landi and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.