Redirecting using .htaccess - .htaccess

I've got an odd redirect request, and I'm not sure if it is possible.
On the server we have a series of PHP files with a name similar to /title-of-the-page-####.php, where #### is an unique integer ID of the page.
I want to be able to redirect users from /#### to the full title of the page (as listed above). Is this possible from within an .htaccess file, and if so, how? (I would like to avoid listing all of the pages from within the .htaccess file)

Related

How to remove default code from url in magento

In my Magento I've created two store so we have now these stores:-
commercial and url :- www.mysite.com/commercial
default and url www.mysite.com/deault
retail. and url www.mysite.com/deault/retail
My commercial url looking good but I want to remove default from these stores :-
deault and url www.mysite.com/deault
and
retail. and url www.mysite.com/deault/retail
If I disable :"Add Store Codes" to Url = no then commercial stores stops working.
Here's an explanation for how to do it:
http://www.crucialwebhost.com/kb/how-to-setup-multiple-magento-stores/#subdirectory-method
Basically you need to manually create the subdirectories and put modified copies of the files index.php and .htaccess inside.
But this assumes that you run the 'default' shop directly on the domain top level directory. Another Stackoverflow post that could give insight into the settings:
Multiple magento stores on single domain

htaccess URL redirect based on page title

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

Redirect based on query string?

I am trying to update the .htaccess file to redirect web users from pages on older version of our site to our current site.
The old PHP files have no direct relationship to file names and extensions used on our current site.
For example:
www.mydomain.com/pages/site/properties/properties.php?id=Smith
To:
http://mydomain.com/properties/sally-smith/
Or:
www.mydomain.com/pages/site/properties/properties.php?id=Jones
To:
http://mydomain.com/properties/robert-jones/
My site has several more pages with same path but with different PHP id's. I am getting stumped on how to handle each individual id in writing a 301 redirect from old pages to their corresponding current pages.

How does Concrete5 arrange it's absolute paths?

I've been asked to figure out how the Concrete5 system works for an employer, and I can't figure something out.
I have Concrete5 installed to a directory on the server called /realprofessionals. When the Concrete5 system makes new pages, it gives them their own absolute paths, for instance:
http://www.wmcpartners.com/realprofessionals/footer
However, it hasn't actually made a folder in the /realprofessionals directory called footer. So how does that work? How can http://www.wmcpartners.com/realprofessionals/footer be a working link?
Short answer: All page requests are actually going through the one and only index.php file. Page content is stored in the database, not in files on the server.
Long answer:
Concrete5 (and most PHP-based CMS's for that matter) work like this: all requests are routed through the index.php file. This routing is enforced with some mod_rewrite rules in the .htaccess file. The rules say "for any request, don't actually go to that page, but instead go to index.php and pass the rest of the requested path as $_GET parameters". Then in the index.php code (or some other code that is included by the index.php file), the requested page is determined based on the path that was put into the $_GET parameters by Apache (as per the mod_rewrite rule in .htaccess), and the appropriate content is retrieved from the database.
Storing content in the database as opposed to files on the server has several advantages. For example, you can re-use the same html template -- header, footer, sidebar -- on every page, and if you change the template it will automatically be reflected on all pages it's used on. Also, it makes it easier to shuffle pages around and to give them whatever URL you want (e.g. no ".php" extension at the end, or /2010/11/date/based/paths/for/blog/posts).
The disadvantage of course is that every request requires many database queries, but for most sites (those without zillions of page views), the trade-off is well worth it (and various types of caching can help reduce the performance hit).
Jordan's answer is excellent, I would add that you probably don't see index.php in the url because you've enabled pretty URLs (type 'pretty' on concrete5's searchbox to check that).
Anyhow, the best way to programmatically add link to internal pages is:
<a href="<?=$this->url('page-name');?>">
page name
</a>
It works both on localhost and online, with or without pretty URLs.
(For the page-name go to dashboard/full sitemap/page-name/properties/page paths and location.)

301 Redirect of Static HTML to Dynamic PHP Page

After upgrading our website, many old links that people have in blogs, etc. are now going to our 404 error page.
An example is: (using h#p b/c I'm a new user and can't post links)
h#p://www.site.com/pressreleases/some_release.html
h#p://www.site.com/pressreleases/another_release.html
These items are now part of a db-driven site and would be live here:
h#p://www.site.com/pressreleases/details.php?id=1
h#p://www.site.com/pressreleases/details.php?id=2
How can I set up the 301 to redirect
h#p://www.site.com/pressreleases/some_release.html
to
h#p://www.site.com/pressreleases/details.php?id=1,
and
h#p://www.site.com/pressreleases/another_release.html
to
h#p://www.site.com/pressreleases/details.php?id=2?
Thanks
Compose a .htaccess file in the pressreleases directory and specify the following:
Redirect 301 some_release.html details.php?id=1
If you would like to redirect using regular expressions, use mod_rewrite as explained here.
There are various options listed on this page.
If you have a lot of these URLs, and assuming you have access to the Apache config, consider creating a "redirects.inc" file in /etc/apache2 (or anywhere really) and then adding "include /etc/apache2/redirects.inc" to your virtual host. That way you have one place to add/update your redirects.

Resources