Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8327595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:09:58+00:00 2026-06-09T01:09:58+00:00

I want to rewrite some URL’s based only on the last parameter. For example:

  • 0

I want to rewrite some URL’s based only on the last parameter. For example:

http://www.site.com/some-param/some-param/THIS-param

I want to grab THIS-param and use that for the rewrite. It always be the last parameter, but not necessarily the 3rd. Could be 2nd, 3rd, 4th, or 5th.

Im getting close with this:

RewriteRule ([^/]+)$ index.php?url_title=$1 [NC,L,QSA]

using this as the url (for example).

http://www.test.com/param1

The problem is, once I add ‘param2’ the site stops working. I think it’s cause param1 appear to be a directory.

http://www.test.com/param1/param2

Any idea why? Here’s my full set of rules:

Options +FollowSymlinks -MultiViews

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f [NC,OR] 
RewriteCond %{REQUEST_FILENAME} -d [NC] 
RewriteRule .* - [L]

RewriteRule ([^/]+)$ index.php?url_title=$1 [NC,L,QSA]
RewriteRule .* index.php [L]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:09:59+00:00Added an answer on June 9, 2026 at 1:09 am

    You nearly had it. You need to capture everything that comes after the last /, and optionally capture what comes before it if needed. You said it coudld be 2nd through 5th, but didn’t mention 1st, so that assumes something comes before it with a /, as in ^.+/.

    This also allows for a trailing /

    Edited to incorporate existing rules:

    RewriteEngine On
    
    # Real existing files not rewritten
    RewriteCond %{REQUEST_FILENAME} -f [NC,OR] 
    RewriteCond %{REQUEST_FILENAME} -d [NC] 
    RewriteRule .* - [L]
    
    #Inelegant hack to permit one param only
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/?$ index.php?url_title=$1 [L,QSA]
    RewriteRule ^.+/([^/]+)/?$ index.php?url_title=$1 [L,QSA]
    # Anything not matching above goes to index.php
    RewriteRule .* index.php [L]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to rewrite from http://example.com/blah/<something>/<somethingelse> to http://<something>.example.com/<somethingelse> , but only if the request
I have a URL like this http://www.freshupnow.com/movie.php?moviename=A+Flat I want to rewrite this URL using
For my website i want to rewrite my url to: www.xxx.com/en/index.php instead of www.xxx.com/index.php?language=en
I want to rewrite an url from example.php?id=123 to example-123-hello-world (where hello-world is some
I want to get a URL scheme exact like SO's question URL. Like http://stackoverflow.com/questions/6035363/so-like-url-with-mod-rewrite
I want to map a number of directories in a URL: www.example.com/manual www.example.com/login to
At the root of my site... www.domain.com . want to add some static pages
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
I want to rewrite http://website.com/?slug=product_info.php&products_id=32 to http://website.com/product_info/32 and I use this code, add_filter('rewrite_rules_array','wp_insertMyRewriteRules'); add_filter('query_vars','wp_insertMyRewriteQueryVars');
I've got the following directory setup: http://www.mysite.com/public/ I'm using the following rewrite to remove

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.