• Question:
    How do I exclude everything in one particular directory directory being rewritten by mod_rewrite. I assume I need a RewriteCond. However I can’t get it to work.

    Background:
    I have sucessfully setup my wordpress and basic permalinks. I’m using pages quite heavily, including images, links to pdf documents etc. in these pages. I have placed all my images and pdfs in a directory called content (eg. https://www.mysite.com/content/).

    When refering to my ‘content’ from pages I want to be able to use a simple URI in the a href tag. Somthing like ./content/picture.jpg rather than hardcoding the full url www.mysite.com/content/picture.jpg or navigating up an undertermined number of directories eg ../../../content/picture.jpg

    Once I turned permalinks on links such as href='./content/images/pdf.jpg' get translated into: https://www.mysite.com/about-me/docs/content/images/pdf.jpg. I assume this is because mod_rewrite is rewriting the base for these links. I would like it not to re_write this beacuse it’s in the directory ‘content’ and it should resolve as www.mysite.com/content/images/pdf.jpg

    Any help would be appreaciated, Thanks.

    .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>
    # END WordPress

Viewing 1 replies (of 1 total)
  • i had the same problem, using images with relative URIs.

    the first solution (which i found somewhere on here):
    use absolute URIs – like <img src=”/folder/file.jpg”> instead of <img src=”folder/file.jpg”> (note the slash after src=”!)

    the second solution would be to add the following lines to wordpress/wp-includes/formatting.php (in line 28):

    $curl = str_replace('href="', 'href="/', $curl);
    $curl = str_replace('href="/https://', 'href="https://', $curl);

    for images, it would be

    $curl = str_replace('src="', 'src="/', $curl);
    $curl = str_replace('src="/https://', 'src="https://', $curl);

    using the second solution, you can keep linking as before, and the changes will be made automatically (and retroactively). external links are “cleaned” of the preceding “root-slash”.

Viewing 1 replies (of 1 total)
  • The topic ‘RewriteCond Mod_rewrite.c Question’ is closed to new replies.