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 7786597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:26:33+00:00 2026-06-01T20:26:33+00:00

I am in process to apply URL rewriting rule based on certain condition in

  • 0

I am in process to apply URL rewriting rule based on certain condition in my .htaccess file but have got struck due to my near to zero level knowledge of URL rewriting using Apache .htacces.Here is my use case

i have few plugins in my WordPress application and those plugins making use to certain CSS and JavaScript,all i want that those URLs should be served from the CDN server, due to some issues i can not use a simple rewrite which will rewrite the URL for entire application as that thing is breaking my application functionality.

http://www.mydomain.com/wp-content/plugins/pluginA/abc.css
http://www.mydomain.com/wp-content/plugins/pluginA/abc.js

i want that when the CSS and JS are from this plugin (Plugin A ) or any other plugin whose URL i want to rewrite, The URL should get rewritten as

http://www.cdn.mydomain.com/wp-content/plugins/pluginA/abc.css
http://www.cdn.mydomain.com/wp-content/plugins/pluginA/abc.js

i am not sure how to do such conditional based URL rewriting,Any suggestion will really be
helpful

Edit
This is my current .htaccess file in the root

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

i have created a new .htaccess file under wp-content folder as per Michael suggestion with following entry

RewriteEngine On
<IfModule mod_rewrite.c>
RewriteBase  /wordpress/
RewriteCond %{REQUEST_FILENAME} ^.+\.(css|js)$
RewriteRule wp-content/plugins/(nivo-slider-light|Usernoise|lightbox-plus|wp-content-slideshow|content-slide)/(.+)$ http:/cdn.cloudfront.net/wp-content/plugins/$1/$2 [L,R=302,QSA]
</IfModule>

but seems this is not working as still for the above plugins all the css and js file are being served with the URL from localhost and not from my CDN server.I even commented out these lines from my root’s .htaccess file

 RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
 RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
 RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

but this also did not made any changes in the URL

  • 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-01T20:26:35+00:00Added an answer on June 1, 2026 at 8:26 pm

    This could be placed in .htaccess inside the root directory. Any plugins you want rewritten can be placed inside the () separated by |.

    RewriteEngine On
    # Rewrite pluginA plugin X, and pluginZ to the CDN. Add add more with |
    RewriteRule wp-content/plugins/(pluginA|pluginX|pluginZ)/(.+)$ http:/www.cdn.mydomain.com/wp-content/plugins/$1/$2 [L,R=301,QSA]
    

    Note: the above rewrites all the plugin files. If it should only be the css & js files, use

    RewriteCond %{REQUEST_FILENAME} \.(css|js)$
    RewriteRule wp-content/plugins/(pluginA|pluginX|pluginZ)/(.+)$ http:/www.cdn.mydomain.com/wp-content/plugins/$1/$2 [L,R=301,QSA]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have patch file describing changes to multiple files to apply to the contents
I would like to automate the results creation process when I apply certain modeling
As the title suggest... How can I apply a scrum process to anything that
Java process control is notoriously bad - primarily due to inadequate support by the
I'm trying to download a file from the web and save it locally, but
We want to apply OO to design a process of taking an exam and
Is it possible / plausible to apply Agile development to the website building process
I have an app in the process of upgrading to the iOS5 SDK and
I would like to rename the .ipa file created after the build process to
Im currently in process of learning Javascript. And I have seen the following code,

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.