close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

HTACCESS Friendly URL doesnt work

Thread began 8/14/2014 11:19 pm by Christopher West | Last modified 8/19/2014 7:09 am by Jamie | 2526 views | 18 replies |

Christopher WestCommunity Expert

HTACCESS Friendly URL doesnt work

Hi , I understand this maybe out of scope on support. but wondered if its possible that anyone can help as I have trailed through websites and tried different approaches.

I would like to change the URL (for example)
http://www.dinkyfingerprintjewellery.co.uk/category.php?Categories=Cufflinks
TO
http://www.dinkyfingerprintjewellery.co.uk/Cufflinks/

I thought this line of code would do it, but it just displays my normal URL
RewriteRule ^([^/.]+)/?$ category.php?Categories=$1 [NC]

its the htaccess file in context...

in my htaccess file I am using the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.dinkyfingerprintjewellery\.co.uk
RewriteRule (.*) http://www.dinkyfingerprintjewellery.co.uk/$1 [R=301,L]
Options +FollowSymlinks
Options -Multiviews
RewriteRule ^([^/.]+)/?$ category.php?Categories=$1 [NC]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]

Sign in to reply to this post

Jamie

Hey Christopher

Not sure about the path that you have suggested (its something I have in my 'to do' list to talk to Ray about' but I use this the following structure on all my dynamic pages - couple of examples: check out the news article links on http://www.ybg.org.uk/news.php or the member links on http://blandfordbusiness.co.uk/members.php

This is how I put it together (and using your suggested domain):

Addition of <base href="http://www.dinkyfingerprintjewellery.co.uk/" > to the target page

Recordset structure (on target page category.php):

(You need to change $RSName, $DBConnection, table_name, Permalink and KeyColumnID to your own references)

<?php
$RSName = new WA_MySQLi_RS("RSName ",$DBConnection,1);
$RSName ->setQuery("SELECT * FROM table_name WHERE KeyColumnID = ? OR Permalink = ?");
$RSName ->bindParam("i", "".(isset($_GET['id'])?$_GET['id']:"") ."", "-1"); //paramOffersID
$RSName ->bindParam("s", "".(isset($_GET['perm'])?$_GET['perm']:"") ."", "-1"); //paramPermalink
$RSName ->execute();
?>



Where the difference lies in what you have put, is the addition of a faux 'folder' in the URL structure

Where you have put:

http://www.dinkyfingerprintjewellery.co.uk/Cufflinks/


I would add a faux folder like this:

http://www.dinkyfingerprintjewellery.co.uk/folder-name/Cufflinks/ (note the addition of /folder-name/ to the structure)


Your raw URL is http://www.dinkyfingerprintjewellery.co.uk/category.php?Categories=Cufflinks

so the htaccess that pulls it all together is

RewriteEngine on

RewriteRule ^folder-name/(.*)$ category.php?perm=$1 [NC,L,QSA,T=application/x-httpd-php]


and all you need to do to link to that page is use the structure like ttp://www.dinkyfingerprintjewellery.co.uk/folder-name/Cufflinks/

Hope this helps?

All the best

Jamie

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Jamie, at the moment my site isnt using mysqi and just want to keep things consistent if that makes sense. PLus would rather refrain from adding to the code in php. What I would like to find out is why my htaccess only method doesnt work. since after looking up various websites the code in htaccess that I am using is the same (there are no errors on the page) its simple just has no effect., and i tried slightly different variations and again has no effect. so I cannot understand why so so many users are using this code and yet when I do nothing happens...what is stopping it from functioning? I know the actual htaccess file is ok since I have other directives in there to redirect www and non www.

Chris

Sign in to reply to this post

Jamie

Totally understand.

In case it helps, this would be the msql version for the RS

<?php
$colname_RSNamePerm = "-1";
if (isset($_GET['perm'])) {
$colname_RSNamePerm = $_GET['perm'];
}

$colname_RSName = "-1";
if (isset($_GET['id'])) {
$colname_RSName = $_GET['id'];
}
mysql_select_db($database_DBConnection, $DBConnection);
$query_RSName = sprintf("SELECT * FROM table_name WHERE KeyColumnID= %s OR Permalink = %s1", GetSQLValueString($colname_RSName, "text"),GetSQLValueString($colname_RSNamePerm, "text"));
$RSName = mysql_query($query_RSName, $DBConnection) or die(mysql_error());
$row_RSName = mysql_fetch_assoc($RSName);
$totalRows_RSName = mysql_num_rows($RSName);
?>
Sign in to reply to this post

Jason ByrnesWebAssist

mod_rewrite is not my strong suit so i cant really offer a lot of assistance on this one, you would probably get better help posting to the webmaster world forums or another forum more specific to mod_rewrite.

however, i think you need a leading forward slash in your rule:

instead of
RewriteRule ^([^/.]+)/?$ category.php?Categories=$1 [NC]

try:
RewriteRule ^([^/.]+)/?$ /category.php?Categories=$1 [NC]

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Jason, I tried that it has no effect. interestingly I know if you do the slightest mistake in HTACCESS that it completely stops the website working..in my case the website is still accessable which means that syntax is playing friendly. I will check out those forums you mentioned.

Also Jamie, I will try your php method on my testing server which will give me more time to experiment. Im just cofused why it cannot work simply by htaccess only method like most users use on the web that I have seen.

Also Jamie, if you know any more on htaccess.Im trying to get Firefox's YSLOW to have a better score, currently I have a score of 82..but this will be a lot higher soon as i upgraded my 1and1 hosting which now supports CDN hosting via cloudflare. which means GZIP and Use a Content Delivery Network will get a score of "A"

the only parts that I score low on are :

Add Expire Headers (Scored F)
Configure Entity Tags (ETags) (Scored D)

I have this snippet of code fr htaccess and wondered if correct as it has no effect on my score if I place this code in:

(also I believe it screws up my CSS file, when I installed it earlier my CSS was wiped..possible cause last night I minified my CSS file and it screwed up the website for some reason...so perhaps it was stilll caching that minifed version).

<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>

<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>

<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
Sign in to reply to this post

Jason ByrnesWebAssist

Just FYI Chris, if I use:
http://www.dinkyfingerprintjewellery.co.uk/Cufflinks

without the trailing slash, i get the proper result. . .

Sign in to reply to this post

Christopher WestCommunity Expert

Hmm...now im confused lol so would this mean that Google or any other search engine would now index this page as http://www.dinkyfingerprintjewellery.co.uk/Cufflinks or would it still only use the ones that are hardcoded in my page navigation links?

Also I think my CDN is messed up as if I do put the trailing slash at the end it displays the website but without any CSS either that or its my a conflict in the HTACCESS?

here is the complete htaccess if anyone would know why the css doesnt show. All I can think is that the CDN is caching the working CSS for the moment.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.dinkyfingerprintjewellery\.co.uk
RewriteRule (.*) http://www.dinkyfingerprintjewellery.co.uk/$1 [R=301,L]

Options +FollowSymlinks
Options -Multiviews
RewriteRule ^([^/.]+)/?$ /category.php?Categories=$1 [NC]

RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]

ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"

# Turn ETags Off
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None

<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
Sign in to reply to this post

Jason ByrnesWebAssist

  Google or any other search engine would now index this page as http://www.dinkyfingerprintjewellery.co.uk/Cufflinks or would it still only use the ones that are hardcoded in my page navigation links?  



search engines will only use the links in your site for indexing.

you would need to change the links in your site and resubmit a site map to the search engines for them to change the way the page is indexed.

Sign in to reply to this post

Christopher WestCommunity Expert

ah and use Jamie's php method would solve this :)

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...