logo
down
shadow

Redirect url depending on the extension


Redirect url depending on the extension

By : user2953764
Date : November 21 2020, 01:01 AM
This might help you You do not need to use the regexp. For DOM manipulation, there are a class for this. Check this:
code :
$text = '<a href="pdf.pdf">pdf</a> texto mas texto por el texto <a href="something.mp3">mp3</a> texto texto mas texto texto texto';
function showHtml($text) {
    $Dom = new DOMDocument;
    $Dom->loadHTML($text);
    $links = $Dom->getElementsByTagName('a');
    foreach ($links as $link) {
        $href = $link->getAttribute('href');
        if (!empty($href)) {
            $pathinfo = pathinfo($href);
            if (strtolower($pathinfo['extension']) === 'mp3') {
                $link->setAttribute('target', "iframeId");
            } elseif (strtolower($pathinfo['extension']) === 'pdf') {
                $link->setAttribute('target', "_blank");
            }
        }
    }
    $html = $Dom->saveHTML();
    return $html;
}
showHtml($text);


Share : facebook icon twitter icon
conditional .htaccess redirect - redirect to two different pages depending on the url

conditional .htaccess redirect - redirect to two different pages depending on the url


By : Akash Patel
Date : March 29 2020, 07:55 AM
will help you My website functions a little like 9gag or damnlol, etc. when the user visits an item page, for example: site.com/104-funny-thing, the rewrite rule redirects to view.php?id=104-funny-thing. Here the URL is stripped away of everything after the first '-'. So we are left with the id only, in this case: 104, and the query gets the item.
code :
#article urls
RewriteRule ^([0-9]+)(-.*)?$ view.php?id=$1

#profile urls.
RewriteRule ^([A-Za-z0-9]+)$ profile.php?username=$1
php, .htaccess - redirect non extension to index + redirect usernames to user page

php, .htaccess - redirect non extension to index + redirect usernames to user page


By : Михаил Мерзляков
Date : March 29 2020, 07:55 AM
should help you out I've searched a lot in google and stackoverflow but didn't find the complete answer... , You may try this:
code :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/([^/]+)?/?([^/]+)?/?([^/]+)?/?   [NC]
RewriteRule .*     index.php?var1=%1&var2=%2&var3=%3   [L]
How to remove php extension and also redirect extensions to no extension form

How to remove php extension and also redirect extensions to no extension form


By : Leonard Thornton
Date : March 29 2020, 07:55 AM
it should still fix some issue According the the answers and my own research, this would be the final answer:
code :
# To remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule ^ /%1 [R=301,L]

# To remove .php extension
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ (.*)\.php [NC]
RewriteRule ^ %1 [R=301,L]

# To check whether the file exists then set it back internally
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^.*$ $0.php [L]

# To redirect /index to root
RewriteCond %{THE_REQUEST} ^.*/index
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
Redirect '.php' extension to non-extension url on WordPress page in Azure through web.config

Redirect '.php' extension to non-extension url on WordPress page in Azure through web.config


By : user32359
Date : March 29 2020, 07:55 AM
I hope this helps . Dependencies: I'm running a WordPress site on an Azure App Service. , Got it. Here's my solution:
code :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Remove any php extensions if it ends in php">
          <match url="^(.*)\.php$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Redirect" url="{R:1}" />
        </rule>
        <rule name="Wordpress" patternSyntax="Wildcard">
          <match url="*"/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
          </conditions>
          <action type="Rewrite" url="index.php"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>
htaccess redirect between subdomains depending on the file extension

htaccess redirect between subdomains depending on the file extension


By : user3713676
Date : March 29 2020, 07:55 AM
With these it helps Situtation , You can do something like the following:
code :
# Identify static resources - set an environment variable
SetEnvIf Request_URI "(?i)\.(jpg|png|gif|mpg|mp4|wmv|js|css)$" STATIC_RESOURCE

# Redirect static resources to static subdomain
RewriteCond %{HTTP_HOST} ^www\.
RewriteCond %{ENV:STATIC_RESOURCE} =1
RewriteRule \.([\w]{2,4})$ https://static.example.com%{REQUEST_URI} [R=301,L]

# Redirect "other" requests to www
RewriteCond %{HTTP_HOST} ^static\.
RewriteCond %{ENV:STATIC_RESOURCE} ^$
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org