htaccess URL redirect based on page title - .htaccess

I would like to add a line to my htaccess to change this url:
RewriteEngine on
do this is the url
http://site/Calendar/viewevent?eventid=9223
into something like this :
http://site/Calendar/viewevent/Title-of-event
its php and joomla and I am a php developer, please dont advise me to use a component or module to handle redirects, I am trying to achieve this using .htaccess ONLY :) thank you in advance!!

Your 'pretty' url contains information that is not in the 'working' url. Besides that, the 'working' url also contains information that is not in the pretty url. You need database access to translate the event id to a seo-title, and the seo-title back to an event id. In other words: It is impossible to do this with .htaccess only, unless you change 'viewevent' to accept an event by seo-title, instead of eventid.
Mod_dbd can possible be used, but only in the server config file, not .htaccess.

As Sumurai8 says htaccess cant transform url like you want automatically.
But you can use Redirect 301 (or its variation) for one url to another.
for your example:
Redirect 301 /Calendar/viewevent?eventid=9223 /Calendar/viewevent/Title-of-event
more information here

Related

Using htaccess to redirect URL from one query string to another

I need to redirect
from
/showthread.php?tid=6
to
/viewtopic.php?t=6
using htaccess. We moved from MyBB to PhpBB and would like to safe links leading to our site.
The domain remains the same. All my attempts failed.
Can someone help?
^showthread.php?tid=(\d+)$ viewtopic.php?t=$1
This should do the trick with htaccess redirect parameter :)

Htaccess redirect rewrite rule custom url

How would I do this please? I am having problems with my htaccess.
suppose I have this url:
www.testingstackzz.com/index.php?action=list&lcp=19
and I want to redirect it to a custom url which I made up like this
www.testingstackzz.com/general/place
where 'place' in the above url is the name for the variable lcp=19 in the database. So lcp=20 would be another place to be more explicit.
In your index.php script, look for the $_GET['lcp'] parameter, look it up in the database, then use header("Location: /general/$name_of_place");
If you only want to limit this to request that directly access the index.php file, then check the $_SERVER['REQUEST_URI'].

How can I redirect and then rewrite url in same file for pretty URL?

I have just been asked to migrate a site from one server to another for a site that I did not build. They have a lot of links to pages that dont exist.
<a href="app/batteries">
This is not actually a directory in the site, but there is an app.php file in the root directory. I have gotten it to display the products by redirecting anything to the app/ directory to app.php?app=. The value of ?app= is dynamic, so any solution would need to be dynamic. I have simply used the redirect statement in the htaccess file to get it to the app.php page. Is there a way to get the url back to the pretty url after a redirect?
Any help would be awesome. Thanks in advance.
You should use ModRewrite instead, for matching a pretty url with regexps, and converting into the url using the app.php.
The rewrite is local to the server, so the visitor sees only pretty urls.

how can i hide the part of url using .htaccess

I am trying to remove the part from my url here is the url "http://example.com/custom_joomla_template-2.5.6/about-us/portfolio/itemlist/category/3-category-2"
Now I want to remove "itemlist/category/" from the url so that url can be look link "http://example.com/custom_joomla_template-2.5.6/about-us/portfolio/3-category-2"
I am using default functionality of joomla i.e. SEF urls, I need to simplify it more I am new for the htaccess
Please suggest link for learning how to write rules for .htaccess file
Please help
Easiest thing is just to make a menu link somewhere that goes directly to category-2. That will set up the url correctly. It will also get rid of the 3-

Can't figure it out: Redirection showing old url

I'm using cpanel and tried using htaccess and it's not working.. I need to redirect prismafoto.com.ar to brujaurbana.com.ar/prisma but when it does the url that is shown is brujaurbana.com.ar/prisma
How can I do this?? thanksss :(
Sounds like you are wanting to do a masked URL redirect. Meaning, you want the domain to redirect but stay the same in the URL bar.
http://webstarthelp.com/forwards.html
The above site has a great Masked URL Redirect.
Simply create a index.html file on prismafoto.com.ar and paste the generated code.
Make sure to clear the .htaccess file so redirects do not conflict.

Resources