0

I have a site in wordpress in which a page is showing questions based on its ID.

http://example.com/index.php/question/?questionid=9&title='how-to-rewite-htaccess' 

I am the beginner to php I'm not able to graps other examples found on stackoverflow.com

Here's my .htaccess code

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteRule ^/question/([^/]*)/([^/]*)/$ /question/?questionid=$1&title=$2 [NC,L] </IfModule> 

But this is not working. please tell where is error.

2

3 Answers 3

2

Since your using Wordpress you can turn on permalinks which takes care of the url friendly urls for you see https://codex.wordpress.org/Settings_Permalinks_Screen.

Login to your admin then go to permalinks and set a preferred style.

Sign up to request clarification or add additional context in comments.

Comments

1

example.com/index.php/question/9/how-to-rewite-htaccess doesn't match your rewrite rule because the rule has a trailing /. Change the regex (first) part of your rewrite rule to:

^/question/([^/]*)/([^/]*)/?$ 

Adding ? makes the trailing / optional.

Comments

0

Once you go to setting > permalinks and set the pretty links, WordPress will automatically generate .htaccess based on the setting you choose. Don't forget to save.

More information here http://www.wpbeginner.com/beginners-guide/why-you-cant-find-htaccess-file-on-your-wordpress-site/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.