Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Rewrite already rewritten url

11 years 5 months ago - 11 years 5 months ago #227177 by PCAnalyzer
Rewrite already rewritten url was created by PCAnalyzer
Hello,
I'm trying to rewrite user's profile url after it has been already rewritten by Joomla.

Htaccess rule:
RewriteCond %{REQUEST_URI} /mio-profile/userprofile/([a-zA-Z0-9_]+)$
RewriteRule ^my-profile/userprofile/([a-zA-Z0-9_]+)$ /${lowercase:$1}/ [L,R=301]

E.g.
I'm rewriting /my-profile/userprofile/username to /username/

The rewriting is working, but I'm getting error 404, page not found. Why?

Thank you.

(I know I can use 3rd party components such as 404sef, but I don't like them, I need rewrite only this kinda of url)
Last edit: 11 years 5 months ago by PCAnalyzer.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 5 months ago - 11 years 5 months ago #227182 by krileon
Replied by krileon on topic Rewrite already rewritten url
It's not working because there's no handler for it. PHP has no idea what that URL means. What happens when going to a page that isn't a user profile? How should Joomla behave? What if the username matches a component or other menu item; go to the user or to the component? Realistically such URLs just don't work well with Joomla as the alias (mio-profile) is what links it to the component followed by task/view. Your best solution is a 3rd party SEF extension that handles the re-routing for you, but you still may run into conflict issues.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 11 years 5 months ago by krileon.

Please Log in or Create an account to join the conversation.

11 years 5 months ago #227186 by PCAnalyzer
Replied by PCAnalyzer on topic Rewrite already rewritten url
Ah, thank you.

Can I do the opposite, then?
I mean rewrite /username/ to /my-profile/userprofile/username which should exists because it's written by Joomla?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 5 months ago #227191 by krileon
Replied by krileon on topic Rewrite already rewritten url
Yes, a write for what you want it to be to what it should be or a permanent redirect in htaccess should work fine. You're going to have massive conflicts though and all URLs for yoursite.com/TEXT/ will try to go to a CB profile.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

11 years 5 months ago - 11 years 5 months ago #227196 by PCAnalyzer
Replied by PCAnalyzer on topic Rewrite already rewritten url
Right, maybe there is a way to check if the url /my-profile/userprofile/username/ exists? Else I don't redirect the url to it...
Last edit: 11 years 5 months ago by PCAnalyzer.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 5 months ago #227226 by krileon
Replied by krileon on topic Rewrite already rewritten url
Custom 404 page can also work. This way valid links go to where they're supposed to. Invalid links go to 404 and attempts to see if the link is a user (using PHP). If it is then redirect and if not then display a typical 404 error page.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum