How do I redirect a page to another page in such a way that they both look the same? - .htaccess

I need to redirect https://example.com/projects/issues/(some_text_here) to http://example.com/i/(same_text_here) in such a way that it /i/(same_text_here) shows the same page that /projects/issues/(some_text_here) shows. Is this possible? How would I do this. Please post the code I would use (along with helpful comments explaining why something goes where it does). Thanks!
EDIT: I believe I would have to use the htaccess file?
EDIT 2: By (some_text_here) I mean so random text, like a wildcard. It could be /projects/issues/34... or /projects/issues/hello. In this case first example should redirect to /i/34, and the second example should redirect to /i/hello

Try this out in your .htaccess:
Redirect /projects/issues/ http://example.com/i/

Related

Redirect issues: New category/article structure / How to get rid of the article id?

I guess, this is an easy one but anyway, I haven't figured it out yet.
After migrating my website from Joomla 3 to Joomla 4 the structure of categories and articles will change. That's why I will need some rules in .htaccess to redirect the old urls to the new ones.
The website is hosted on an Apache server.
The old URL structure looks something like that.
https://www.mydomain.de/category/subcategory/item/[articleID]-[articleAlias].html
[articleID] is a digit.
[articleAlias], e.g. „this-is-article-number-233“
This should be redirected to...
https://www.mydomain.de/newcategory/newsubcategory/[articleAlias].html
An example:
https://www.mydomain.de/category/subcategory/item/2324-this-is-my-latest-article.html
… should be redirected to...
https://www.mydomain.de/newcategory/newsubcategory/this-is-my-latest-article.html
I've played around with RedirectMatch and Rewrite Rule but haven't been successful to make it work. How do I get rid of the article id?
My latest try failed with...
RedirectMatch ^category/subcategory/item/([0-9]+)-(.*)$ /newcategory/newsubcategory/$1
Is there a simple and elegant solution to this? Thanks in advance!
UPDATE
Maybe it's more complex than I thought it was.
Main problem is that not only my categories changed but also the ids of the articles.
So, to stick with my example...
https://www.mydomain.de/category/subcategory/item/2324-this-is-my-latest-article.html
first turns into something like:
https://www.mydomain.de/newcategory/newsubcategory/1223-this-is-my-latest-article.html
Anyway, Joomla 4 is able to drop the article id automatically (guess with an internal rewrite) for seo-friendly URLs. I activated that feature to make the new URLs look like
https://www.mydomain.de/newcategory/newsubcategory/[articleAlias].html
The [articleAlias] stays the same.
A redirection according to what you actually ask should be possible like that:
RewriteEngine on
RedirectRule ^/?category/subcategory/item/[0-9]+-(.*)\.html$ /newcategory/newsubcategory/$1.html [R,L]
However I doubt that this really is what you want: this completely drops the numeric ID of the resource. Which means that it won't be available for processing when the redirected request comes back requesting the new, stripped URL. How do you want to internally rewrite that request back to the internal resource then, without that ID?
I made some more tests and it this is the final solution to my problem:
RedirectMatch 301 ^/?category/subcategory/item/[0-9]+-(.*)\.html$ /newcategory/newsubcategory/$1.html

Trying to create seo friendly url

I'm trying to create friendly url for my site but with no success :(( and i have two questions
The first is:
How to change the url from domain.com/page/something.php to domain.com/something
And the second is:
Will the changes make duplicate content and if how to fix the problem.
Thank you for your time,
Have a nice day
Check out the official URL Rewriting guide: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
You'll be using the simplest use case, Canonical URLs. Assuming you have no other pages that you need to worry about, you can use a rule like this: (note: untested, your usage may vary)
RewriteRule ^/(.*)([^/]+)$ /$1$2.php
While that example might not exactly work for your use case, hopefully reading the guide and my example will help you get you on your way.

.htaccess redirect pagination

At present my url structure of page is like this
Mysite.com/page-2
mysite.com/categoryname/page-2
I want to change it to
mysite.com/page/2/
mysite.com/category/categoryname/page/2/
Note that, I have multiple page, i.e. let's say a category have 100 page so I need to redirect all the earlier page number to the new url structure. Writing code of every url will be too tedious. I am not sure but using $ in the code can help.
Please let me know how can it be done via .htacess.
Thanks in advance.
Your URL structure is already with the desired one you have as I can see.
/category/telecom-news/page/2

Redirect to target url and add query string

I'm trying to redirect just one page on a site to another one using htaccess. I'm new to this, but have been reading and reading everywhere to figure out how to do this, but without success.
I would like to redirect www.example.se to www.example.se/index.php?template=<templatename>
Is that possible and how would I approach that? So sorry if I'm asking a stupid question here, but really can't find a solution and it's driving me crazy.
Try:
Redirect / /index.php?template=<templatename>
Add a 301 right after Redirect if you want it to be permanent.

Htaccess change url to directory url

For example, I want:
http://site.com/cool.php?page=woohoo
http://site.com/cool.php?page=yoyoyo
To show this in the browser:
http://site.com/woohoo/
http://site.com/yoyoyo/
How do I do this?
Check this answer: https://stackoverflow.com/a/8446690/995958
It gives a nice way to do exactly what you want to do.
Other answers are useful too if you have problems with the confirmed one.

Resources