---
# System prepended metadata

title: '[Ruby On Rails]建立假連結(結尾為.php,.aspx..等)'
tags: [Ruby On Rails]

---

# [Ruby On Rails]建立假連結(結尾為.php,.aspx..等)　
###### tags: `Ruby On Rails`


terminal建一個controller
```terminal
rails g controller main
```

controllers/main_controller.rb
```ruby=
class MainController < ApplicationController
    def index
    end
end

```



config/routes.rb
```ruby=

Rails.application.routes.draw do
  get 'main.php' => 'main#index'
end

```

views/main/index.html/erb
```ruby

<h2>Main Page(this is not php!!)</h2>

<%= link_to  "fake link", controller:"main",action:"index" %>

```

就可以產生結尾為.php的假連結了






