0

I could not create dynamic post through URL by .htaccess, Page or Post redirect automatically 404 page.

I have tried Redirection Plugin, but i could not successfully redirect. Please try to give me solution, Thanks in advance.

Original Url - https://example.com/subject-detalis?type=daily&sign=topic

Modify Url - https://example.com/subject/daily/topic

.htaccess code:

Options +FollowSymLinks
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

RewriteEngine On 
RewriteRule  ^subject/(\d+)?$ ./subject-detalis?sign=$1&type=$2
8
  • If subject-details is a WordPress page/post/category/etc., you should use add_rewrite_rule() instead of the RewriteRule.
    – Sally CJ
    Commented Jul 25, 2019 at 8:53
  • I am not using pages or post category in this project. This is totally dynamic pages. Commented Jul 25, 2019 at 13:13
  • So the subject-details is a file or folder, which is not handled by WordPress?
    – Sally CJ
    Commented Jul 25, 2019 at 14:29
  • 1
    I'm saying, is that example.com/subject-details a WordPress Page (post type of page)? If so, use add_rewrite_rule(). In WordPress, you'd only want to use the RewriteRule if you're rewriting to a file other than the WordPress' main index.php file. Otherwise in your case, WordPress will try to load a Page with the slug subject/daily/topic and if not found, results in the 404 error.
    – Sally CJ
    Commented Jul 25, 2019 at 15:32
  • 1
    Thank You, So much ! @SallyCJ , It's working ! Commented Jul 26, 2019 at 15:19

0

Your Answer

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

Browse other questions tagged or ask your own question.