Odd URL RewriteRule Behaviour - .htaccess

Hoping someone with better experience can guide me on this.
Ref: https://www.donbur.co.uk/gb-en/news/index.php
This is a dynamically generated news summary list with a button link to article pages. Until last week, the button links worked fine.
Each link calls a URL
<a class="button" href="https://www.donbur.co.uk/news/<?php echo rawurlencode($row_newsResult['newsurlkey']);?>">Read full article</a>
This parses fine.
To process this link, I've then got an htaccess RewriteRule:
RewriteRule ^news/([^/]*)$ /gb-en/news/article.php?title=$1 [L]
The article.php file then uses the unique title to identify and show the full article.... or at least that's what it should do and has done.
For whatever reason, from the news index.php page, when the link is clicked, it just refreshes the page and re-writes the URL to
https://www.donbur.co.uk/gb-en/news/index.php/[uniquetitleparameter]?title=[uniquetitleparameter]
The parts in brackets [] obviously get populated with the rawurlencoded string.
I cannot for the life of me understand what is happening here - especially when I have a similar page, doing a very similar thing, works absolutely fine (https://www.donbur.co.uk/gb-en/features/feature-list.php)!!!!
This all started going wrong when I converted the site from http to https: but can't work out if that's relevant??

Turns out this was just a bad caching issue. Temporarily disabled cache as suggested and all works well.

Related

How to remove bits from the url using the htaccess file?

Hi I am using joomla for my website and I would like to remove the bits in between my url.
The original URL:
"/calums/index.php/component/jsjobs/jsjobs/employer/"
The way I want it to be:
"/calums/employer/"
It would be great if some one can help me work out how to do it using the htaccess file.
Thanks.
first of all you need to enable SEF in Joomla to get rid of the /index.php/ part:
enable sef in global configuration (the first two checkboxes)
copy your htaccess.txt to .htaccess
This is transparent and should make your URL look like this:
/calums/component/jsjobs/jsjobs/employer/
Then, by looking at your URL, it appears the component jsjobs doesn't have a menu item associated. Menu items are associated with views, so you should go into menu manager and add a new menu item and try to setup menu items for jsjobs. You might not find one that matches exactly but you should be partway there.
Once a menu item is setup (and the cache is cleared) you should begin to see
/component/jsjobs replaced at a minimum. If there is no menu item that produces the right url, then you might have to create an .xml file in the component/view folder you desire. More details in this answer: Joomla Developement :: Probleme with URL Rewriting
my first answer on stackoverflow. try this:
RewriteEngine on
RewriteRule ^(\w)/(\w)/(.*) $1/index.php/component/jsjobs/jsjobs/$2/$3

.htaccess correct format for RewriteRule

I have a "JQueried" page using tabs - Tab A, Tab B etc the tabs hide/show content based on a link like this: Tab 1 I am using jQuery Address Plugin v1.4
http://www.asual.com/jquery/address/ to create new page titles and a new URL for each tab. If you do not know the Address Plugin recreates the URL so the link #tab1 creates the URL page.html#tab1 but without a page refresh. It also changes the page title but is there any way to create an RewriteRule so that http://domain/page.html#tab1 can be called by say http://domain/tab1.html (where tab1,tab2 etc. have proper names not tab!)
Have tried but don't seem to get it to work. e.g.
Options +FollowSymlinks
RewriteEngine on
RewriteRule about.html /test.php#tab1 [NC]
suggestions please. Thanks in advance - oh the htaccess will go in the actual root folder
Sorry, I checked \#, it didn't work for me either.
How about redirecting to test.php?hash=tab1, and then:
if (isset($_GET["hash"]))
header ( "Location: test.php#".$_GET["hash"] );
Based on my comment above - I have just found this stackoverflow.com/questions/8606127/mod-rewrite-hash-tags so I guess can't be done –

Multiple subdirectory error with mod_rewrite

I am trying to use mod_rewrite manually in joomla, and I have the following Rule:
RewriteRule ^test/(t1|t2|t3)-(.*).html$ /index.php?option=com_jumi&fileid=39&$1=$2 [L,NC]
So that I want the url
http://www.mysite.com/index.php?option=com_jumi&fileid=39&t1=foo
be displayed like
http://www.mysite.com/test/t1-foo.html
The rule works correctly, but when I am in the rewritten page the links like
http://www.mysite.com/link.html
or
http://www.mysite.com/xxx/link.html
become
http://www.mysite.com/test/link.html
or
http://www.mysite.com/xxx/test/link.html
respectively.
any suggestions?
thank you
You are using relative urls in your page. Your page contains a link like <a href="link.html">... and the browser makes the links relative to the current 'folder', namely "test", so when clicked the browser loads /test/link.html.
You should just use root-relative urls. So the link should become more like <a href="/link.html">.... The leading '/' makes the browser load the page relative to the root ("/"), not relative to "/test/".

Htaccess Rewriterule virtual directories breaking all links

I think I've gone through a million articles and everyone's codes on this, but I just can't get it to work! Every code I try works but it shows the redirect url instead of the virtual one.
I would like mysite.com/company/client/ to actually show the results from mysite.com/company/client.php, but the files within client.php become broken unless I make absolute links.
For instance mysite.com/company/css/style.css is broken when viewing from http://mysite/company/client/, but is working fine when going to the real file mysite.com/company/client.php
I hope someone knows how to solve this problem without having to change all links in client.php to absolute!
Thanks!
Scott
You might want to consider the HTML BASE tag:
...
<head>
...
<base href="http://mysite/company" />
...
</head>
...
You put this in the client.php file, then any relative link & reference is automatically "converted" to an absolute one, starting from the right folder.
See the comments on possible issues with the BASE tag.
Another option would be to perform a redirect instead of a rewrite, by adding "[R]" to the RewriteRule. However, then your users will see the "client.php" in the URL.

url rewrite rule

so my first page is index, then from index i call a page called vetements where i include a get variable called cat wich is the category of wear, then when im on vetements page i call a sub category(here i stay on vetements page(the page redraws itsel with php) the problem is im unable to combine this 2 rules in htaccess
my links should look like:
vetements-Robes-Robes-courte
vetements is the name of the page itself
Robes is category
Robes-courte is sub category
right now this rule works when im on page vetements:
RewriteRule ^vetements-(.*)-(.*-.*) /vetements.php?cat=$1&sous_cat=$2 [L]
but it wont work when i go from index to vetements, to make it work from index to vetements i have to do the following:
RewriteRule ^vetements-(.*)-?(.*-.*)?
but then it wont work in vetements(when i redraw the page to call the sub category)
thanks for your help
maybe try a rewerite like this:
RewriteRule vetements-cat-(.*)-sous_cat-(.*)\.htm$ vetements.php?cat=$1&sous_cat=$
this is what was suggested by http://www.webconfs.com/url-rewrite-tool.php
You might also want to look at other tutorials and examples on creating so-called "search-friendly URLs" since that's essentially what you're trying to accomplish.
Does your index page have vetements-Robes-Robes-courte in the link to vetements page?

Resources