-
September 12th, 2009, 12:32 PM
#1
Friendly URLs with .htaccess and <A NAME> links?
Hi guys.
I've got a site I've been building for a few months for a client, it's a pretty big thing and is really nearly done.
I've used mod_rewrite in the .htaccess file to remap the URLs to be user friendly (Eg, index.php?act=music&aid=35 becomes /bands/AllTimeLow/)
Problem is, I've also used <A NAME> links in some sections to jump the page to a specified section.
The question, how do I use name links with frienfly urls? As the link appends #NAME to the url, it messes up and tried to load /#NAME.
I cant find anything with Google so I'm hoping someone can give me an answer or alternative Cheers!
-
September 12th, 2009, 12:52 PM
#2
Re: Friendly URLs with .htaccess and <A NAME> links?
What does your .htaccess code look like? Are you allowing for extra characters in it? Or are you just truncating the string to load the exact URL variables?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 12th, 2009, 01:18 PM
#3
Re: Friendly URLs with .htaccess and <A NAME> links?
It's all a bit messy but:
Code:
RewriteEngine On
# Exclude rules
RewriteRule ^.+(/images/.+)$ /indie$1 [L]
#RewriteRule ^.+(/include/.+)$ /indie$1 [L]
RewriteRule ^.+(/user_content/.+)$ /indie/$1 [L]
RewriteRule ^.+(layout.css)$ /indie/layout.css [L]
# Make the trailing slash optional on friendly URLs
RewriteRule ^music$ music/ [L]
RewriteRule ^bands?$ index.php?act=music&list [L]
RewriteRule ^bandregister?$ index.php?act=musicregister [L]
RewriteRule ^user?$ index.php?act=user [L]
RewriteRule ^photos?$ index.php?act=photos [L]
RewriteRule ^messagecenter?$ index.php?act=message [L]
RewriteRule ^messagecenter/sent?$ index.php?act=message&func=sent [L]
# Friendly URLs
RewriteRule ^music/$ index.php?act=music&home [L]
RewriteRule ^bands/(.*)$ index.php?act=music&bname=$1 [L]
RewriteRule ^user/(.*)$ index.php?act=user&name=$1 [L]
RewriteRule ^postusercomment/$ index.php?act=user&func=postcomment [L]
RewriteRule ^reportuser/(.*)$ index.php?act=user&func=report&uid=$1 [L]
RewriteRule ^userphotos/(.*)$ index.php?act=user&func=photos&uid=$1 [L]
RewriteRule ^messagecenter/sent/(.*)$ index.php?act=message&func=read&id=$1&sent [L]
RewriteRule ^messagecenter/(.*)$ index.php?act=message&func=read&id=$1 [L]
RewriteRule ^profileedit$ index.php?act=user&func=edit [L]
RewriteRule ^message/(.*)$ index.php?act=user&func=msg&uid=$1 [L]
RewriteRule ^photos/(.*)$ index.php?act=photos&page=$1 [L]
RewriteRule ^viewphoto/(.*)$ index.php?act=photos&pid=$1 [L]
RewriteRule ^usersearch/(.*)$ index.php?act=user&func=search [L]
RewriteRule ^verify/(.*)$ index.php?userregpage=verify&code=$1 [L]
RewriteRule ^news/(.*)$ index.php?id=$1 [L]
RewriteRule ^morenews/(.*)$ index.php?act=olderposts&start=$1 [L]
RewriteRule ^download/(.*)$ include/weekly-song-download.php?title=$1 [L]
This is my first time using mod_rewrite, and in fact any htaccess stuff. Most of my previous projects haven't needed to be user friendly haha.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|