1

I have the following url

http://localhost/mybb/index.php?url=widgetboard/questions&step=1&id=1

which turns into the following url after applying rewrite rule

http://localhost/mybb/widgetboard/questions/step/1/id/1

Is it possible to remove the 2 words ie "step" and "id" from the url and add .html at the very end of the url

my code is

Options -MultiViews

# turn rewriting on
RewriteEngine On

# When using the script within a sub-folder, put this path here, like /mysubfolder/
# If your app is in the root of your web folder, then please delete this line or comment it out
RewriteBase /mybb/

RewriteRule ^(.+?)/(step)/([0-9]+)/(id)/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5 [NC,L,QSA]

RewriteRule ^(.+?)/(category)/([0-9]+)/(answer)/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5 [NC,L,QSA]

RewriteRule ^(.+?)/(step)/([0-9]+)/?$ index.php?url=$1&$2=$3 [NC,L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ index.php?url=$1&$2=$3 [NC,L,QSA]

2 Answers 2

1

You can insert this rule just below RewriteBase /mybb/ line:

RewriteRule ^([^/]+)/([^/]+)/([0-9]+)/([0-9]+)/?$ index.php?url=$1/$2&step=$3&id=$4 [L,QSA]
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for replying late. It worked great. Thanks once again for your help.
0

Change your second rule to:

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?step=$1&id=$2 [NC,L,QSA]

Then if a user clicks this url: domain.com/3/120 your PHP script will receive index.php?step=3&id=120

1 Comment

I tried but didn't work.Actually I have another param in the url which is "url".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.