I've been implementing tidy urls and querystrings into my site but can't get querystrings to resolve AND show the page correctly - all links become relative to the 'faux' directory
I'm using
RewriteRule ^services/([0-9]+)/?$ services.php?sv=$1
in .htaccess
so /services/2 becomes /services.php?sv=2
but the resulting page displays incorrectly.
I can only think that it's impossible to use relative links when using tidy urls and querystrings but I can find no mention of this anywhere.
Standard link: http://www.tomatedesign.com/sample-site/services.php?sv=2 as normal with querystring
and finally: http://www.tomatedesign.com/sample-site/services/2 tidy URL with a querystring
The RewriteRule is doing its job, services/1, services/2 and services/3 all get the correct content included on the page just everything else is broken.
actually I just had to include
<base href="/">
in the file to have the page resolve the links appropriately
Related
I am creating a CodeIgniter site. I have an SEO problem to address. The following URLs all point to the same page, although search engines see them all as different urls:
www.yahoo.com
http://www.yahoo.com
http://www.yahoo.com/
Does CodeIgniter have a function that can automatically redirect pages to a single URL?
if not, has anyone written a function that can create a unifying URL for the redirect?
Currently I am redirecting all pages to:
"http://-----.com/" . uri_string();
Use canonical URLs. Basically you tell the search engines that when they pull up that page by any of those URLs that the one you specify as the canonical URL is the one to be considered the "main" URL and shown in their index. The others are then not considered duplicates.
<link rel="canonical" href="http://www.yahoo.com/" />
I have the following mod_rewrite using Proxy flag to redirect from one URL folder to another site subdomain as follow:
The .htaccess file placed inside http://www.domain.com/test/ folder:
RewriteEngine on
RewriteRule ^($|/.*) http://subsite.site.com/$1 [L,P]
The problem, images, CSS and links are not showing up properly. Links appear to be pointing back to: http:// www. domin .com/linkname.html
I've tried doing RewriteBase /test/ and / with no luck, and couldn't figure out any other way to do it.
What am I missing in above code to make it work with relative paths at destination URL?
Oh, you want to change internal content?
Mod_rewrite only changes headers, not content and you would definitely need something else like mod_proxy_html. However, rewriting content just to change urls can normally be completely avoided (assuming you have control of your content) by making all paths legitimately relative. In such cases all paths in content should be like: linkname.html or some_path_from_here/linkname.html instead of /linkname.html or some_path_from_here/linkname.html
I need your help. I have a Joomla site working. I enabled it friendly urls and it works fine. All rewritten URLs are this way
http://mydomain.com/start/article-page-well-rewritten
When I activate Joomla Cache plugin, when I load page first time, it works fine, but afterwards, it doesn't load any css or image file.
Debugging resulting html, I realized cached file has these images and CSS links
mydomain.com/start/images/coolimage.jpg
mydomain.com/start/css/stylesheet.css
Instead of
mydomain.com/images/coolimage.jpg
mydomain.com/css/stylesheet.css
(real routes)
So I think I need a rewrite rule to remove word "start" from url, and then retrieve them and show, but only to image and css files from mydomain.com/start/
Can you help me how to do it? I don't want anything else to be rewritten...
RewriteRule ^start/(images|css)/(.+) /$1/$2 [R]
I'm using Joomla 1.5.14 and I configured SEO as in the following image
Now I need to map a few old URL to the new site
let's say that I need to map htp://mysite/old.html to the new Joomla page
http://mysite/index.php?option=com_content&view=article&id=32&Itemid=70
I added in my .htaccess file the following
RewriteRule ^old\.html$ index.php?option=com_content&view=article&id=32&Itemid=70 #works!!
this works fine, but if I use the SEF URL in .htaccess (let's say the above page can be reached with htp://mysite/contacts.html), I obtain a 404 error
RewriteRule ^old\.html$ contacts.html #this does not work
Now the question:
Is it possible use SEF URLs in RewriteRule? where am I wrong?
thank you in advance
stefano
I think the problem is because Apache rewrites old.html to a page that doesn't actually exist, but rewritten in a different rule.
If you truly want to "rewrite" - in other words, have the page stay as old.html in the browser - then you don't need to do anything.
However to avoid duplicate content it's probably better to do a 301 redirect:
Redirect 301 old.html http://yoursite.com/contact.html
(You may need a forward slash at the front of old.html)
I need some help with rewrite rules and nested URLs.
I am using TikiWiki for my website and am in the process of setting up SE friendly URLs for my projects. Specifically, I have the following rewrite rule for www.example.com/projects to point to a page that lists out all the projects hosted in example.
RewriteRule ^Projects$ articles?type=Project [L]
This works fine.
Now, I would like to point www.example.com/projects/project1 to point to a specific project.
I have this rewrite rule
RewriteRule ^(Projects/Project1)$ tiki-read_article.php?articleId=6
This works, but partially. The content is all rendered as text but the theme - images/ css etc all go for a toss - the page is completely in text.
I understand that this happens 'cause the relative paths in the theme/ css/ images all refer to Projects as the base folder instead of the root of the website.
I don't want to touch the CMS portion - change the theme/ css/ image paths in the files, more for reasons of upgradability.
Can someone help me understand and write a rule so that the above nested URL works?
Regards,
Radha
You need to either change the CMS or write rewrite rules for your theme/CSS/image files. For example, if your images are in the /images/ directory within the site, try
RewriteRule ^Projects/(themes/.*)$ \1
or perhaps better
Alias /Projects/themes /themes
But still, I'd edit the CMS configuration if it were me.
Relative URLs are resolved to absolute URLs on the base of the base URL that is the current document’s URL. So in your case the base URL is /projects/project1 and not /projects although your files are actually located there. Because the client uses only URLs and has no clue about the actual file system. And the current document’s URL is /projects/project1.
So use URL references with an absolute URL path (/projects/css/…) instead of relative ones.