I have been trying to rewrite dynamically generated URLs to static URLs. For example I achieve this URL after implementation of .htaccess command:
Rewritten URL: http://www.risenotes.com/top/Love-best-quotes
while actual URL is: http://www.risenotes.com/quotes/great-best-quotations.php?topic=Love
I am using below command for this purpose:
RewriteEngine On
RewriteRule ^top/([^/]*)-best-quotes$ /quotes/great-best-quotations.php?topic=$1 [L]
My code works perfectly well for above but I want to redirect all requests for
/quotes/great-best-quotations.php?topic=Love
to newly rewritten URL
/top/Love-best-quotes.
Can anyone guide me please???
Related
I am trying to rewrite URLS in my website but unable to do so.
I am using Lightspeed in Cyberpanel. The .htaccess code I used is:
RewriteRule ^([^/d]+)/?$ index.php?id=$1 [QSA]
What my url looks right now: mysite.tld/index.php?a=2322
What I want to look it like: mysite.tld/2322
Thanks in advance!
I'm working on an integration with Yiiframework and Joomla. I have it working for the most part, but want to make it a little cleaner. The URL that is called in Joomla needs to get some URL Parameters appended to the URL. I have setup the .htaccess to rewrite the URL, but it's not working and I can't figure out why. Please help.
What the URL current is:
/index.php?r=site/index
What I want it to append is "option=com_jumi&fileid=3" so it looks like this
/index.php?r=site/index&option=com_jumi&fileid=3
Here is what I have for the rewrite
RewriteCond %{QUERY_STRING} ^r=(.*)$ [NC]
RewriteRule ^/index.php$ /index.php?r=%1&option=com_jumi&fileid=3 [NC,L,R=301]
Looking for some guidance, thanks
I have a slight issue. I have configured my default controller as :
c$route['default_controller'] = 'news';
so when I point my browser to http://localhost/mysite all the news get loaded as instructed by the news controller.
Now on this page, I have given links to "read article" to read the full article. For this I have to point my browser to http://localhost/index.php/news/view/news-slug. I want to remove index.php from the url. I had already tried re-routing using wildcard without any success. Can you tell me how to do that?
There is a documentation on removing the index.php from the URL if you are using Apache with it's mod_rewrite:
Removing the index.php file
Using the following rewrite code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also, there are many similar questions to yours, have a look at these questions from the search:
Search query on removing index.php in Codeigniter
You need to define your .htaccess file for this. Check this wiki: http://codeigniter.com/wiki/mod_rewrite
I have some legacy code that needs to be used in a new application. I would like to write the new application in CodeIgniter, but I still need to have some way of accessing the old code. what I would like to do is have an exception in the routing so that any url that has the format of example.com/old_stuff/* goes to an old_stuff folder, and acts as a regular, un-routed applications, while any other url such as example.com/new_stuff would route to a new_stuff controller, for example. So essentially what I want it to have URLs behave as they usually would in CodeIgniter, with the exception of any that start with one certain string.
What's the best way to accomplish this?
place codeigniter at your web root, and have your folder old_stuff in the web root also.
then use .htaccess with these rules (assuming you have mod_rewrite)
RewriteEngine on
RewriteCond $1 !^(index\.php|images|old_stuff|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
then, a uri beginning with old_stuff will just serve up the content bypassing codeigniter.
OK...
I have setup things so that when the following page is requested (browser users and servers)
http://www.visualise.ca/?_escaped_fragment_=corona
the website returns the following the content of this (HTML snapshot)
http://www.visualise.ca/corona
Where 'corona' always change, it varies depending on the page the users or servers are requesting. It could also be
http://www.visualise.ca/?_escaped_fragment_=anne-au-cherry
redirecting to
http://www.visualise.ca/anne-au-cherry
Thanks
UPDATE: OK let me be more clear. I use AJAX to load my Wordpress post and they appear like this http://www.visualise.ca/#!/corona when loaded. But it's not crawlable by Google that request to serv them as http://www.visualise.ca/?_escaped_fragment_=corona so I modified Wordpress to do so. Now Google can crawl my page and index its content and accessing the HTML snapshot available at http://www.visualise.ca/corona.
The problem is that when I paste the http://www.visualise.ca/#!/corona link to facebook it seems to read the http://www.visualise.ca/?_escaped_fragment_=corona and is unable to read the content. But when I paste directly the http://www.visualise.ca/?_escaped_fragment_=corona link it works, it reads http://www.visualise.ca/corona (The HTML).
So I thought maybe if I could redirect http://www.visualise.ca/?_escaped_fragment_=corona to http://www.visualise.ca/corona it would solve my problem.
Here is the existing .htaccess file
#--- DH-PHP handlers ---
AddHandler fastcgi-script fcg fcgi fpl
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/dispatch.fcgi
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The common mistake that a lot of people do is trying to match whole URL including query string. The reality is: when matching URL, the pattern get applied to path part of it and query string has to be matched separately.
Use this rule: it will issue 301 Permanent Redirect from this kind of URL /?_escaped_fragment_=corona to /corona (where corona can be anything).
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=([^&]*)
RewriteRule .* http://%{HTTP_HOST}/%1? [R=301,L]
I guess your question is really "how do I do this kind of redirection?". So the answer is here:
There are three ways that I could think of, each with slight differences.
Doing the redirection server side
This basically means you set redirect headers in your response. In php, you could do this using the header function. It can also do a delayed redirect, in which case you need to worry about the contents of the page.
Doing it using client side using html's "http-equiv" meta tags. This way the page always gets loaded. Example here.
doing it via javascript. Thats you basic document.location.href thing. You need to figure out a way to pass the argument to javascript, or have your JS read it from the address url itself.
Since I've shown you 3 ways of doing this, I really hope that's what you're looking for :P
Update after seeing the comments:
The above methods will cause the URL to change. If you don't want the URL to change, but show the contents of that other page on your original page, you caould either do that using iframes (baaaad), or do the decent thing and set up URL rewriting.
:)
RewriteEngine on
RewriteRule \?_escaped_fragment_=(.*?) /$1 [L,R=301]
is it what are you looking for?