Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
.htaccess - Remove apostrophe from URL
Old 09-24-2012, 09:55 PM .htaccess - Remove apostrophe from URL $$$
pappasaa's Avatar
Ultra Talker

Posts: 273
Trades: 0
I grabbed this turnkey directory script that i am fixing up and i am good with fixing the php and sql bugs but i am not familiar with htaccess rewrites.

Some of my listings are normal like "Eat Place" and others are "Joe's Eat Place" and I am not sure how to get rid of the apostrophe(s).

Free help is great but I would be glad to shoot a $10 spot for a hand.


Code:
ErrorDocument 404 /404err.php

Options +FollowSymlinks
#php_value magic_quotes_gpc off
RewriteEngine on

RewriteRule ^FCKeditor/(.*) FCKeditor/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
RewriteRule ^search/(.*)$ search_results.php?key=$1&keyword=$2 [L]
RewriteRule ^browse/(.*)$ search_results.php?key=$1&type=tags [L]
RewriteRule ^place/(.*)$ search_results.php?keyword=$1 [L]
RewriteRule ^user/(.*)/tags/(.*)/from/(.*)$ profile.php?user_id=$1&tags=$2&from=$3 [L]
RewriteRule ^user/(.*)$ profile.php?user_id=$1 [L]
RewriteRule ^(.*).html$ listings.php?catname=$1 [L]
RewriteRule ^(.*)/(.*)/(.*).htm$ listing_details.php?bname=$3 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*).htm$ listing_details.php?bname=$4 [L]
RewriteRule ^(.*)/(.*)/(.*).htm$ listing_details.php?bname=$3 [L]
RewriteRule ^(.*)/(.*).htm$ listing_details.php?bname=$2 [L]
RewriteRule ^(.*).htm$ listing_details.php?bname=$1 [L]
__________________
visit my link...um...nevermind

Last edited by pappasaa; 09-24-2012 at 10:05 PM..
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
 
Register now for full access!
Old 09-25-2012, 08:47 AM Re: .htaccess - Remove apostrophe from URL
chrishirst's Avatar
Defies a Status

Posts: 43,957
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
from my regexp library, no idea where I got it from originally
Code:
# remove apostrophes from a string
Rewriterule ^([^/]*)'([^/]*)$ $1$2 [N,E=redirect:1]
This line should go immediately before your redirect Rewriterule

If you want to know how it works group 1 ($1) matches all characters from the string start (^) to the literal apostrophe ('). Group 2 ($2) matches all characters from the literal to the string end ($) then concatenates $1 & $2. The [N] (Next) flag tells the regex engine to loop around the rules using the new string as a start point until no matches occur.
The [E] flag set an environment variable 'redirect' to 1 so Apache can keep track of what needs to happen when the regex engine finishes
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-25-2012, 11:27 AM Re: .htaccess - Remove apostrophe from URL
pappasaa's Avatar
Ultra Talker

Posts: 273
Trades: 0
Quote:
Originally Posted by chrishirst View Post

If you want to know how it works...
Answer...always!

I will test this out and get you some feedback here soon. Thank you
__________________
visit my link...um...nevermind
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Old 09-25-2012, 11:57 AM Re: .htaccess - Remove apostrophe from URL
pappasaa's Avatar
Ultra Talker

Posts: 273
Trades: 0
I found a tutorial online with the same solution but I could not get it to work for me. Do i have it placed correctly?

Code:
ErrorDocument 404 /404err.php

Options +FollowSymlinks
#php_value magic_quotes_gpc off
RewriteEngine on
RewriteRule ^FCKeditor/(.*) FCKeditor/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /
Rewriterule ^([^/]*)'([^/]*)$ $1$2 [N,E=redirect:1]
RewriteRule ^search/(.*)$ search_results.php?key=$1&keyword=$2 [L]
RewriteRule ^browse/(.*)$ search_results.php?key=$1&type=tags [L]
RewriteRule ^place/(.*)$ search_results.php?keyword=$1 [L]
RewriteRule ^user/(.*)/tags/(.*)/from/(.*)$ profile.php?user_id=$1&tags=$2&from=$3 [L]
RewriteRule ^user/(.*)$ profile.php?user_id=$1 [L]
RewriteRule ^(.*).html$ listings.php?catname=$1 [L]
RewriteRule ^(.*)/(.*)/(.*).htm$ listing_details.php?bname=$3 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*).htm$ listing_details.php?bname=$4 [L]
RewriteRule ^(.*)/(.*)/(.*).htm$ listing_details.php?bname=$3 [L]
RewriteRule ^(.*)/(.*).htm$ listing_details.php?bname=$2 [L]
RewriteRule ^(.*).htm$ listing_details.php?bname=$1 [L]
Also, I took a look at how the link is formatted on the page itself and does not seem to have anything special about it and have not (yet) found anything outside of the .htaccess file that would cause a rewrite.

Code:
<a href="<?=SITE_PATH?>listing_details.php?id=<?php print $line[id]?>"  class="blue_txt"><?php echo ucwords(stripslashes($line['title'])); ?></a>
__________________
visit my link...um...nevermind
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Reply     « Reply to .htaccess - Remove apostrophe from URL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16376 seconds with 11 queries